HistographicDataUpdationProblemSolved #1
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem:
while showing the graph on the CoinInfo.js page, you have used the UseState hook which eventually creates a glitch. That is when the user toggle from different timelines on the page. In that case, useEffect renders the page first and fetches the data for the graph afterward. And because of this, for some duration, it shows the graph of the previously selected timeline. And if API is somehow not able to fetch data, then in that case also it shows the graph of the previously selected timeline which is completely wrong.
Eg:-
Suppose a user select 24 hours timeline to view the graph, then the page will render and after that, the historicData hook get updated and shows the graph on the screen, and after some time, if the user select 365 days timeline, then in that case page will render again and this time before running useState hook function, it will show the graph of previously saved data until that fetchhistoricdata function is not executed completely.
Solution:
I have attached a boolean flag variable whose value will become false when a user selects a timeline, and it gets true when data is completely fetched from the function fetchHistoricData and once the flag becomes true, then only data will be visible on the screen.