Skip to content
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

fix: Await should fallback on route params navigations #9181

Merged
merged 4 commits into from
Aug 24, 2022

Conversation

brophdawg11
Copy link
Contributor

I was a bit naive in the "is revalidating" check to determine when to await all deferred values. We need to distinguish current loaderData for the same route and the same params versus same route but different params since we do want to fallback by default in the latter case (i.e., navigating /invoices/1 -> /invoices/2`).

Closes #8914

@changeset-bot
Copy link

changeset-bot bot commented Aug 22, 2022

🦋 Changeset detected

Latest commit: 1f9b461

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@remix-run/router Patch
react-router Patch
react-router-dom Patch
react-router-dom-v5-compat Patch
react-router-native Patch

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

@brophdawg11 brophdawg11 changed the title fix: fallback on route params navigations fix: Await should fallback on route params navigations Aug 22, 2022
@brophdawg11 brophdawg11 merged commit 26e8b8e into dev Aug 24, 2022
@brophdawg11 brophdawg11 deleted the brophdawg11/defer-fallback branch August 24, 2022 15:05
@danillewin
Copy link

danillewin commented Apr 30, 2023

Hello @brophdawg11, hope you are doing well

I have a question: will this work if i change SearchParams, e.g. during pagination? /users?page=1 -> /users?page=2

In my case, it seems to be not working, unfortunately. I'm changing SearchParams using setSearchParams, and after it loader is fired, returning deferred object, but Suspense Fallback not Rendering(only renders on first load)

When I use route params for pagination - it works well: /users/1 -> /users/2.

I guess, from your commits, that the problem is isNewRouteInstance function:

return (
    // param change for this match, /users/123 -> /users/456
    currentMatch.pathname !== match.pathname ||
    // splat param changed, which is not present in match.path
    // e.g. /files/images/avatar.jpg -> files/finances.xls
    (currentMatch.route.path?.endsWith("*") &&
      currentMatch.params["*"] !== match.params["*"])
 );

There's a check for pathname matching, which will yield true if SearchParams have been changed (only my humble hypothesis)

I'm stuck for hours with this issue and will appreciate your help)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants