Next.js Discord

Discord Forum

Data isn't updated in the edit page after editing it

Unanswered
Bigheaded ant posted this in #help-forum
Open in Discord
Bigheaded antOP
Hey everyone, Have anyone here ever experienced when editing data from the edit page then you successfully edit it and are redirected back to the list page of the data and when you try to return to the edit page again, the data that has been edited still uses the previous data. and to be able to change it you need to refresh the page first. How we can fix this issue?

1 Reply

Roseate Spoonbill
It's hard to pinpoint source of your issues based on the description you gave. We don't know if form or list are client or server components, where form takes data from, if or how data is cached and how the navigation happens.

Here is a few things I'd check:
- If you use cache, calling revalidateTag or revalidatePath in server action should return both updated UI and action result to the form page.
- If you don't use cache, you can always run router.refresh() to make the page update itself.
- Running navigation too early might prevent next from updating local cache in case revalidation was done
- If your form has a state and it's not destroyed after submit, you might need to reset it to default state, or make sure, the form is unmounted after going back to the list (I doubt this is the case, but just mentioning it in case it spawns any ideas on your end)