#Should all parent route DB queries be being run every time any child route is accessed?

1 messages · Page 1 of 1 (latest)

tepid nymph
#

While I'm in development mode I have drizzle logging all queries in my console happening at all times. I'm noticing as I'm working on child routes that the DB queries needed to render all the way out to the outemost parent routes are being called. However, as I watch the Network tab in the browser dev tools, only the child routes I'm working on are being loaded.

On the one hand, the browser dev tools appear to be showing me that RR7 is working as expected, not doing full page reloads with each click of a link (child/nested routes). But If I didn't know any better, based on the DB console activity, I'd say that everything down to the parent-most route is being called and rendered with every click.

Is this expected behavior? Can database queries in loaders be called and data returned without rerendering everything? I'm still pretty new to React/Remix/RR so I'm just trying to know what's "normal." 🙂

topaz comet
#

yes, all loaders are fetched on any client-side navigation

#

you could use shouldRevalidate in each route to control when to fetch it again

#

or you can use a clientLoader to manually decide when to fetch the server loader

#

or what IMO is better, cache the DB queries so you can fetch the loader again without that actually running the DB queries