Layout routes always revalidates with SSR disabled #12427
Unanswered
mrtinsvitor
asked this question in
Q&A
Replies: 1 comment 1 reply
-
@mrtinsvitor curious if you figured this out... |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I'm setting up a new project using the new React Router 7 but without SSR for now. I noticed that my root route and any other layout route with nested routes always revalidates and re-renders the app.
So for instance, if I have a layout route with some nested routes, and I need a
clientLoader
on the layout route, that loader will run anytime I navigate between the layout's nested routes. This wouldn't be ideal for my app, as I may want to fetch some data on my layout route which will feed into my nested routes, and I don't want to refetch it every time I navigate back and forth between the routes.I tried using
shouldRevalidate
function and returningfalse
, as mentioned on the docs, but that doesn't seem to make much difference. I was doing pretty much the same with React Router 6 and wasn't facing this issue. I wonder if I'm missing something?To reproduce this you can just create a fresh project running
npx create-react-router@latest
, set thessr
flag tofalse
, create a layout route with two routes. This is myroutes.ts
:On my login route I have a
Link
to forgot password route, when I click it, my layoutclientLoader
re-runs.I'm using:
react-router 7.0.1
react 18.3.1
vite 5.4.11
Beta Was this translation helpful? Give feedback.
All reactions