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

Reduce RouterProvider re-renders when using View Transitions #11803

Merged
merged 8 commits into from
Jul 17, 2024

Conversation

brophdawg11
Copy link
Contributor

@brophdawg11 brophdawg11 commented Jul 15, 2024

By memo-ing the future prop and DataRoutes we can avoid unnecessary re-renders when we set the ViewTransitionContext

Copy link

changeset-bot bot commented Jul 15, 2024

🦋 Changeset detected

Latest commit: 07dc5db

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

This PR includes changesets to release 4 packages
Name Type
react-router-dom Patch
react-router 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

Comment on lines -728 to +736
future={{
v7_relativeSplatPath: router.future.v7_relativeSplatPath,
}}
future={routerFuture}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Memoized above to ensure object stability across re-renders

>
{state.initialized || router.future.v7_partialHydration ? (
<DataRoutes
<MemoizedDataRoutes
Copy link
Contributor Author

@brophdawg11 brophdawg11 Jul 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has to React.memo this in order to avoid unnecessary re-renders of route components when we updated ViewTransitionContext.

I would have thought I'd have needed to memoize Router as well but it doesn't appear that one needs to be changed...I'm unsure why though?

@brophdawg11 brophdawg11 changed the base branch from dev to release-next July 16, 2024 12:54
@brophdawg11 brophdawg11 changed the base branch from release-next to dev July 16, 2024 12:58
@brophdawg11 brophdawg11 changed the base branch from dev to v6 July 16, 2024 18:02
@brophdawg11 brophdawg11 merged commit a252428 into v6 Jul 17, 2024
3 checks passed
@brophdawg11 brophdawg11 deleted the brophdawg11/vt-perf branch July 17, 2024 15:28
Copy link
Contributor

🤖 Hello there,

We just published version 6.25.1-pre.0 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!

Copy link
Contributor

🤖 Hello there,

We just published version 6.25.1 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.

1 participant