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 useMatches returning different loader data on sub navigation on client side #5603

Merged
merged 5 commits into from
Mar 1, 2023

Conversation

wizardlyhel
Copy link
Contributor

Problem: useMatches returning different route match data on sub navigation. This problem isn't obvious because the last useMatches hook call always returns the correct route's loader data

https://stackblitz.com/edit/remix-run-remix-askr4f?file=app/root.tsx

Navigate between home, test and test 2 page.

  1. On full page reload, you will see multiple logs from useMatches of the same route (This is fine and it is due to React re-renders)
  2. On sub navigation, you will see multiple logs from useMatches but of different route loader data. It is always the current route and the previous route

Notice that the server side console only logs loader data for the correct route

@changeset-bot
Copy link

changeset-bot bot commented Feb 28, 2023

🦋 Changeset detected

Latest commit: 4a178d1

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

This PR includes changesets to release 18 packages
Name Type
@remix-run/react Patch
@remix-run/testing Patch
create-remix Patch
remix Patch
@remix-run/architect Patch
@remix-run/cloudflare Patch
@remix-run/cloudflare-pages Patch
@remix-run/cloudflare-workers Patch
@remix-run/css-bundle Patch
@remix-run/deno Patch
@remix-run/dev Patch
@remix-run/eslint-config Patch
@remix-run/express Patch
@remix-run/netlify Patch
@remix-run/node Patch
@remix-run/serve Patch
@remix-run/server-runtime Patch
@remix-run/vercel 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

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented Feb 28, 2023

Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳

@brophdawg11
Copy link
Contributor

Replaces #5556 and #5601

@brophdawg11
Copy link
Contributor

Thanks @wizardlyhel! I'll get this merged once CI finishes 👍

@brophdawg11 brophdawg11 self-assigned this Mar 1, 2023
@brophdawg11 brophdawg11 merged commit 19a7f34 into remix-run:dev Mar 1, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2023

🤖 Hello there,

We just published version v0.0.0-nightly-3d92d46-20230302 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

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