noStore() doesn't work?
Unanswered
Chilean jack mackerel posted this in #help-forum
Chilean jack mackerelOP
I'm following the Dashboard App tutorial and I'm on the static & dynamic rendering chapter:
https://nextjs.org/learn/dashboard-app/static-and-dynamic-rendering
I've added
When I add
to the
But
https://nextjs.org/learn/dashboard-app/static-and-dynamic-rendering
I've added
noStore(); to all the fetch funcs. But when I change the data in the DB, clicking to other pages and back to the dashboard doesn't update the data on the page.When I add
export const dynamic = "force-dynamic" to the
page.tsx, that seems to make the dashboard load dynamically when routed to the dashboard page.But
noStore() only causes the data to update when I refresh the browser, which seems to be the same behavior as when noStore() isn't present.35 Replies
Chilean jack mackerelOP
Conceptually, I am also wondering why we mark the fetch as dynamic/noStore, and if we couldn't instead simply mark the component itself as dynamic, defining the behavior at the component level instead of the data level.
I could see cases for both approaches, I suppose... though marking the entire page as dynamic, as in the case of the
I could see cases for both approaches, I suppose... though marking the entire page as dynamic, as in the case of the
export const dyanmic fallback, does seem suboptimal.Chilean jack mackerelOP
I guess chapter 9 does address how to "stream" components instead of a page
still, not sure why noStore isn't working
@Chilean jack mackerel I'm following the Dashboard App tutorial and I'm on the static & dynamic rendering chapter:
https://nextjs.org/learn/dashboard-app/static-and-dynamic-rendering
I've added `noStore();` to all the fetch funcs. But when I change the data in the DB, clicking to other pages and back to the dashboard doesn't update the data on the page.
When I add
`export const dynamic = "force-dynamic"`
to the `page.tsx`, that seems to make the dashboard load dynamically when routed to the dashboard page.
But `noStore()` only causes the data to update when I refresh the browser, which seems to be the same behavior as when noStore() isn't present.
do you get updated data displayed if you refresh the page after you change the data in db?
Chilean jack mackerelOP
Yes I did, but I seemed to get updated data on refresh even without nostore
Only with the "dynamic" const set does it update on page swap
Chilean jack mackerelOP
any more ideas on this
noStore tell nextjs not to static generate the page at build timethe page will be dynamic in dev mode as always
Chilean jack mackerelOP
I see... interesting that
export const dynamic = "force-dynamic" behaves differently however. It seems I must use that to allow the page to update on navigate, rather than only on browser page refresh.With noStore the data updates only if the page refreshes.
@Chilean jack mackerel With noStore the data updates only if the page refreshes.
how do you update the data? with the ui or directly in db?
Chilean jack mackerelOP
I'm following the Dashboard App tutorial, and so far I've been updating the data directly in the db for testing this.
if you update the data directly in db, sure you have to refresh the page
Chilean jack mackerelOP
but that's not the case when I export dynamic = force-dynamic
well I don't think it will made any different
it is not websocket or any real time update
Chilean jack mackerelOP
no, but when i navigate away from the page then navigate back -- no page refresh -- the data updates IF I export
dynamic as force-dynamicin that case the page shows the updated data on navigate
in other words it calls the db functions again on navigate, whereas with noStore, it does not
oh ok
export const dynamic = 'force-dynamic' made the whole page dynamicand where you put
noStore at? in the fetch function body right?try putting
noStore in the page componentChilean jack mackerelOP
hm ok. I can try that. Partly I'm concerned that the tutorial may not be totally accurate, or else I don't understand what it is saying. It says to put noStore in the db functions
it is accurate
but putting noStore in the db function != export const dynamic = 'force-dynamic'
you are using
export const dynamic = 'force-dynamic' to compare with noStore in db functionChilean jack mackerelOP
that was the implication in the tutorial, but I suppose it doesn't say they're equivalent, just that one is considered stable but noStore is experimental.
it doesn't say they are equivalent?
Chilean jack mackerelOP
I guess that answers my question, mostly. I probably just need to study up on what these APIs actually do more
no it doesnt
thanks
np hope it make you clear