Layout routes always revalidates with SSR disabled #12427
Unanswered
mrtinsvitor
asked this question in
Q&A
Replies: 2 comments 1 reply
-
@mrtinsvitor curious if you figured this out... |
Beta Was this translation helpful? Give feedback.
1 reply
-
Would love an answer here. Experiencing the same issue. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
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