next-learn icon indicating copy to clipboard operation
next-learn copied to clipboard

Chapter 8: Question to the use of unstable_noStore() inside data access functions.

Open don-esteban opened this issue 1 year ago • 2 comments

Hi all,

From the docs:

unstable_noStore can be used to declaratively opt out of static rendering and indicate a particular component should not be cached.

In the tutorial, we use unstable_noStore() inside data access functions. Not inside components, as the docs imply. Basically, we force components, using the data access functions, to dynamic rendering.

Wouldn't it be better to make this behavior explicit at the component level in @/app/dashboard/page.tsx?

don-esteban avatar Feb 24 '24 14:02 don-esteban

Meanwhile, I passed chapter 12. Probably it needs some experience to find the right level for placing noStore and caching actions.

If my understanding is correct, the tutorial aligns with API functions like cookies, headers and others. Using these functions opt routes into dynamic rendering. The same as the data access functions with unstable_noStore() do. Similar, Server Actions in chapter 12 trigger redirects and cache revalidations.

don-esteban avatar Feb 25 '24 21:02 don-esteban

An easier way to think about this is it controls the data sent from server. It can be whole component or methods that fetch data. unstable_noStore() tells Next.js which data to recompute again.

shivashp avatar Mar 24 '24 14:03 shivashp