-
Notifications
You must be signed in to change notification settings - Fork 805
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
Jetpack: update react-router-dom from v5 to v6 #40773
Conversation
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Follow this PR Review Process:
Still unsure? Reach out in #jetpack-developers for guidance! Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
} | ||
|
||
componentDidUpdate( oldprops ) { | ||
// We need to handle the search term not only on route update but also on page load in case of some external redirects | ||
if ( oldprops.location !== this.props.location ) { | ||
this.onRouteChange( this.props.location ); | ||
} |
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.
There's no direct upgrade path for this, but hopefully this roughly the same thing as before.
243b30a
to
93b00f6
Compare
projects/plugins/jetpack/_inc/client/components/jetpack-notices/plan-conflict-warning.jsx
Outdated
Show resolved
Hide resolved
projects/plugins/jetpack/_inc/client/components/navigation-settings/index.jsx
Outdated
Show resolved
Hide resolved
I think I see why the E2Es are failing. Formerly, due to lack of jetpack/projects/plugins/jetpack/_inc/client/admin.js Lines 56 to 58 in f66d303
/recommendations . But that was ok, since jetpack/projects/plugins/jetpack/_inc/client/recommendations/index.jsx Lines 214 to 334 in f66d303
Now, though, we get the
AFAICT, to fix all this we need to make that be |
P.S. Something that's really confusing is that v6 allows absolute paths in nested routes for something like <Routes>
<Route path="/foo/*" element={<Foo />}>
<Route path="/foo/bar" element={<FooBar />} />
</Route>
</Routes> but doesn't for a case like ours which looks more like <Routes>
<Route path="/foo/*" element={<Foo />} />
</Routes> with <Routes>
<Route path="/foo/bar" element={<FooBar />} />
</Routes> So until you come across remix-run/react-router#10321 / remix-run/react-router#9841 that explicitly point this out, you're likely to find confusing results talking about it working because they only consider the first case. |
In manual testing, all the routes other than the recommendations stuff seem to work. 👍 Waiting on the build to test the new |
I had a hard time figuring out where to test this, but in the end went to Settings → Discussion, toggled on "Comments", and modified the "Comment form introduction" text field, then tried to navigate away:
It worked in |
It gives me a blank screen in JN. Compiling a dev build locally, I get an error about "useBlocker must be used within a data router". Once I jump through hoops to fix that (apparently instead of
In other words, it seems borked if you use actual links for navigation. 🙄 At this point I'm inclined to punt, revert 86ffa45 and just update the comment saying we might use |
This reverts commit 86ffa45.
Co-authored-by: Brad Jorsch <[email protected]>
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.
E2Es are happy, recommendations seem happy, let's do it.
This is PR bumps Jetpack-the-plugin to use
react-router-dom
to v6 (and ultimately to v7).Proposed changes:
Essentially I followed this guide:
https://reactrouter.com/6.28.0/upgrading/v5
Of note:
<Prompt>
is no longer supported in v6, so I've commented the one instance out.withRouter
instances were updated. These really should have been upgraded prior to moving to v5.1 (e.g. in Update/react router 5 #15514 or Update dependency react-router-dom to v5.2.0 #15821), but better late than never.history.listen
was updated (h/t @anomiex for a solution here); see inline comment.That last item could probably use the most scrutiny in a code review.
Other information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions: