Issue with useEffect and POST API call
Answered
Peruvian Inca Orchid posted this in #help-forum
Peruvian Inca OrchidOP
this is my page.tsx of /donate route, the problem which I'm facing is that, whenever the page is reloaded, it posts empty array to the API
Answered by Peruvian Inca Orchid
I managed to fix by adding some more conditions to the POST method
3 Replies
that sounds right... useState isn't persisted across reloads... you might want to use session or local storage (or url params) to save it and then set the state in a useEffect
Masai Lion
@riský what he said. This is basic react if you can avoid data fetching inside useEffects next js provides a lot of ways to do what you are going for
Peruvian Inca OrchidOP
I managed to fix by adding some more conditions to the POST method
Answer