You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the end state of the Address Book tutorial, when I navigate between contacts, the sidebar.tsx (layout) revalidates (loader is called).
According to https://remix.run/docs/en/main/route/should-revalidate, (if I understood it correctly) it should have optimized such that navigating subroutes (/contacts/:contactId) should not cause parent routes/layouts (/ or sidebar.tsx) to be revalidated.
By default, Remix doesn't call every loader all the time. There are reliable optimizations it can make by default. For example, only loaders with changing params are called. Consider navigating from the following URL to the one below it:
/projects/123/tasks/abc
/projects/123/tasks/def
Remix will only call the loader for tasks/def because the param for projects/123 didn't change.
It's safest to always return defaultShouldRevalidate after you've done your specific optimizations that return false, otherwise your UI might get out of sync with your data on the server.
I'm able to work around it with export const shouldRevalidate in sidebar.tsx, but I'm trying to understand the logic behind defaultShouldRevalidate.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
In the end state of the Address Book tutorial, when I navigate between contacts, the
sidebar.tsx
(layout) revalidates (loader
is called).According to https://remix.run/docs/en/main/route/should-revalidate, (if I understood it correctly) it should have optimized such that navigating subroutes (
/contacts/:contactId
) should not cause parent routes/layouts (/
orsidebar.tsx
) to be revalidated.I'm able to work around it with
export const shouldRevalidate
insidebar.tsx
, but I'm trying to understand the logic behinddefaultShouldRevalidate
.Thanks!
Beta Was this translation helpful? Give feedback.
All reactions