Client component not rendering re-fetched data
Answered
フェイン (Fane) posted this in #help-forum
I have a server component rendering a client component, and a server action to fetch, update, then refetch the data. The structure looks like this:
https://gist.github.com/vim-diesel/37b8488e5d6e6a68c7744dabf4b4eab3
No matter what I do, re-fetching the data, revalidating path, the client component is always one step behind. I have confirmed it each time I reload the page, the data is updating in the database, but not being updated properly before being sent to the client component.
https://gist.github.com/vim-diesel/37b8488e5d6e6a68c7744dabf4b4eab3
No matter what I do, re-fetching the data, revalidating path, the client component is always one step behind. I have confirmed it each time I reload the page, the data is updating in the database, but not being updated properly before being sent to the client component.
Answered by フェイン (Fane)
Answered my own question. The revalidatePath() call needs to go in the server action that fetches the data, not the one that updates it. This doesn't make any sense to me.
2 Replies
Answered my own question. The revalidatePath() call needs to go in the server action that fetches the data, not the one that updates it. This doesn't make any sense to me.
Answer
I guess I should mentions this is nextjs 14