-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Fix fetcher revalidation logic #10344
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
Conversation
brophdawg11
commented
Apr 14, 2023
- Fetchers no longer revalidate on search param changes or when routing to the same URL
- Also fixed a semi-related bug where fetcher.load redirects wouldn't be marked as done on the completion of the redirect
🦋 Changeset detectedLatest commit: 53698a6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test flow no longer triggers a fetcher revalidation
packages/router/router.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This captures fetcher.load redirects now as well
packages/router/router.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a bug before as well - but since fetcher's were too-eagerly revalidating it wasn't common to have a fetch-driven redirect that triggered zero loaders.
packages/router/router.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure that if any fetch redirects got cleaned up we commit them
packages/router/router.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Track fetcher.load redirects as well so they can get cleaned up on completion of the redirect navigation
- Fetchers no longer revalidate on search param changes or when routing to the same URL - Also fixed a semi-related bug where fetcher.load redirects wouldn't be marked as done on the completion of the redirect
99b3acc to
7603a77
Compare
| }); | ||
|
|
||
| it("revalidates fetchers on searchParams changes", async () => { | ||
| it("does not revalidate fetchers on searchParams changes", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change tests asserting the old incorrect behavior
| actionResult, | ||
| defaultShouldRevalidate, | ||
| // Forced revalidation due to submission, useRevalidate, or X-Remix-Revalidate | ||
| defaultShouldRevalidate: isRevalidationRequired, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the crux of the bug fix. Fetchers should not use the same logic as routes (which takes into account search params and same-URL navigations). They should only revalidate on action submissions, router.revalidate, or X-Remix-Revalidate
|
🤖 Hello there, We just published version Thanks! |
|
🤖 Hello there, We just published version Thanks! |