Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HistographicDataUpdationProblemSolved #1

Merged
merged 1 commit into from
Dec 30, 2021

Conversation

Siddharth352
Copy link
Contributor

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.

@Pujarini
Copy link

Pujarini commented Dec 30, 2021

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.

Thanks for this solution! We will consider your PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants