Next.js Discord

Discord Forum

App Directory: Trigger update in other component after mutation

Unanswered
Brown bear posted this in #help-forum
Open in Discord
Brown bearOP
Hi all! Is there a way to trigger a refetch in another component after updating some data? E.g. in some deep route I delete an entry and I want to show the entry count in a sidebar that is placed in the root layout.
I tried revalidateTag, but as far as I understand it only marks the cache as invalid, it doesn't refetch itself.

12 Replies

Brown bearOP
Ah so I can just revalidatePath('/')? But that means that everything will get refetched, right?
yep
i have a somewhat related demo
but instead of fetch im using random number generator
so im not sure if it behaves the same for next's fetch()
Brown bearOP
Thanks for the example alfon! Do you maybe have a link to the example's source code?
Brown bearOP
I'm not sure if I understand how the refetching works.
If I understand the docs correctly, revalidatePath doesn't actually load any data, it just invalidates it. How do I load the up-to-date data then? If I currently delete an entry, I have to reload the entire page in order for the sidebar to show the up-to-date entry count.