setState based on SWR fetched data #1020
Unanswered
laurent512
asked this question in
Q&A
Replies: 1 comment 7 replies
-
You don't need to put it in a state at all. You can just use useEffect(() => {
setChartOptions(...)
}, [myDataObject['stockvalue'].data]) |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I am trying to display multiples graphs in a single chart.
To update the chart, I have a setState hook setChartOptions which include the serie I want to display.
With my code below , the chart stays empty.
Very likely because the initial state of the hook is not refreshed after data is loaded ; data remains undefined.
Could you explain me what is the best way to define a state based on data fetched from SWR?
(any example code would be very helpful)
Thank you so much
Beta Was this translation helpful? Give feedback.
All reactions