revalidateTag doesn't work
Unanswered
Schneider’s Smooth-fronted Caima… posted this in #help-forum
Original message was deleted.
6 Replies
Asiatic Lion
AFAICT, from the documentation,
With
revalidateTag will not update the UI automatically (live revalidatePath)With
revalidateTag you probably need to start a new request after the server action, eg. router.refreshSatin
All that calling
You could e.g. make sure that the code responsible for doing the fetch, is called again as part of a useEffect, a callback function or whatever.
You can also use libraries such as SWR that provides hooks for easily refetching data https://swr.vercel.app/docs/mutation
revalidateTag or revalidatePath does, is that the next time a fetch using those tags or that path will be called, the fetch will know to actually fetch the data anew, and not serve cached content. It's still up to you to make sure that the fetch call is happening. You could e.g. make sure that the code responsible for doing the fetch, is called again as part of a useEffect, a callback function or whatever.
You can also use libraries such as SWR that provides hooks for easily refetching data https://swr.vercel.app/docs/mutation
umm, no,
revalidateTag should work the exact same way as revalidatePath. in fact they are just wrapper of an internal revalidate functions: https://github.com/vercel/next.js/blob/27469901350749a930b3ccf99a2c65dbbf7c5346/packages/next/src/server/web/spec-extension/revalidate.ts#L13-L45you do not have to manually update the UI by something like
router.refresh() after calling revalidateTagif your
revalidateTag doesn't work, that's due to a code bugAsiatic Lion
Nice 😄
Seems like that might be an accidental feature right now. Wonder if it's intended to be supported in the future.
// TODO: only revalidate if the path matches
store.pathWasRevalidated = trueSeems like that might be an accidental feature right now. Wonder if it's intended to be supported in the future.