useState is not working
Answered
Greek Harehound posted this in #help-forum
Greek HarehoundOP
In my client component I'm using useEffect and useState to get data from API and it works well... But if i come from another page to home page data is not set by useState.
22 Replies
can i ask why you are using axios (server side fetching library) in client side?
Greek HarehoundOP
I just tried, I was using fetch
so if you directly go to the page it works? but if from another page (using next/link) it doesn't fetch?
Greek HarehoundOP
Yes
It fetches
But it doesn't set the data
I can see the data when i log
o.O
Greek HarehoundOP
it is really weird
are you on latest nextjs version?
Greek HarehoundOP
"next": "13.4.19",
try the latest version
Answer
Greek HarehoundOP
Okay
Greek HarehoundOP
yarn add next@latest react@latest react-dom@latest eslint-config-next@latest
yeah looks good
Greek HarehoundOP
Okay i'll keep you updated
Yes this is working
Ahaha thank you
yay, it seems like a bug was fixed sometime 🎉
Greek HarehoundOP
Yes
I'm closing this issue