Revalidate tag in useState
Unanswered
Pixiebob posted this in #help-forum
PixiebobOP
I tried to revalidate a tag after the user successfully submitted the form to immediately update the data. I stored the current data in useState, but since the server is revalidated, the state doesn't update automatically. As a result, I had to use useEffect. Does anyone know how to update the data with the revalidate tag without using useEffect?
1 Reply
Tomistoma
As far as I know, revalidateTag only works to purge the cache and change anything on the UI, hence it doesn't trigger a re-render to get an immediate feedback. Using useEffect solves the issue for you because when the initialData changes, you set the new state.
You may check using revalidatePath instead or check out either SWR or React Query.
You may check using revalidatePath instead or check out either SWR or React Query.