Skip to content

Parent clientLoader doesn't revalidate when a child route is changed #13264

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
stevan-borus opened this issue Mar 19, 2025 · 1 comment
Closed

Comments

@stevan-borus
Copy link

I'm using React Router as a...

framework

Reproduction

stackblitz repro

System Info

System:
    OS: macOS 15.3.2
    CPU: (8) arm64 Apple M1 Pro
    Memory: 216.94 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
Binaries:
    Node: 20.12.2 - ~/.nvm/versions/node/v20.12.2/bin/node
    npm: 10.9.0 - ~/.nvm/versions/node/v20.12.2/bin/npm
    pnpm: 10.5.0 - ~/Library/pnpm/pnpm
    Watchman: 2024.08.26.00 - /opt/homebrew/bin/watchman
Browsers:
    Chrome: 134.0.6998.89
    Edge: 134.0.3124.68
    Safari: 18.3.1
npmPackages:
    @react-router/dev: ^7.4.0 => 7.4.0 
    @react-router/node: ^7.4.0 => 7.4.0 
    react-router: ^7.4.0 => 7.4.0 
    vite: ^6.2.2 => 6.2.2

Used Package Manager

pnpm

Expected Behavior

The parent clientLoader should always revalidate when its child route is changed, without setting shouldRevalidate = () => true;

Actual Behavior

In the repro, v7.1.5 is set and for that version, the parent clientLoader revalidates when the child route is changed by clicking on one of the links in the parent component, so the selected link which is set in the parent clientLoader can also change

In later versions, the parent clientLoader only revalidates when shouldRevalidate is explicitly set to true
shouldRevalidate = () => true;

This is happening when ssr: false

@brophdawg11
Copy link
Contributor

This is expected behavior for "SPA Mode" apps and matches the original pre-Single-Fetch behavior for revalidations, where routes only revalidate if their params change or after a submission. A GET navigation between child routes should not be mutating any data so the loader should not need to re-run by default.

The behavior in 7.00 -> 7.1.5 was incorrect because the "single fetch" de-optimization of revalidating reused loaders on GET navigations was being incorrectly applied to SPA mode where there is no running server, and thus no "single fetch" HTTP call to make. We fixed this and removed the de-optimization for SPA Mode apps in 7.2.0 via #12948.

@brophdawg11 brophdawg11 closed this as not planned Won't fix, can't repro, duplicate, stale Apr 8, 2025
@brophdawg11 brophdawg11 removed their assignment Apr 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants