Next.js Discord

Discord Forum

useState is not working

Answered
Ibizan Hound posted this in #help-forum
Open in Discord
Ibizan HoundOP
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.
Answered by riský
try the latest version
View full answer

22 Replies

can i ask why you are using axios (server side fetching library) in client side?
Ibizan HoundOP
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?
Ibizan HoundOP
Yes
It fetches
But it doesn't set the data
I can see the data when i log
o.O
Ibizan HoundOP
it is really weird
are you on latest nextjs version?
Ibizan HoundOP
"next": "13.4.19",
try the latest version
Answer
Ibizan HoundOP
Okay
Ibizan HoundOP
yarn add next@latest react@latest react-dom@latest eslint-config-next@latest
yeah looks good
Ibizan HoundOP
Okay i'll keep you updated
Yes this is working
Ahaha thank you
yay, it seems like a bug was fixed sometime 🎉
Ibizan HoundOP
Yes
I'm closing this issue