Repository navigation
fix(react-router): route-context being available and loaders being called after a redirection - #1713
Conversation
☁️ Nx Cloud ReportCI is running/has finished running commands for commit d65e453. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 4 targetsSent with 💌 from NxCloud. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
…in routeContext.test.tsx
cb38f0b to
1a03f7f
Compare
…router into test/route-context-on-navigate
The patch implemented by @freshgiammi in #1662 Co-Authored-By: Gianmarco Rengucci <[email protected]>
| if (!this.isServer) { | ||
| this.navigate({ ...err, replace: true, __isRedirect: true }) | ||
| this.load() | ||
| // this.load() |
| }) | ||
| }) | ||
|
|
||
| function createContextRouter<TCtx extends Record<string, unknown>>( |
There was a problem hiding this comment.
Removed since this is no longer representative of what's actually happening in the browser.
Plus these test-cases are already covered in tests/routeContext.test.tsx.
|
Hello, It seems that this version introduced a bug. I have a simple router with an export const Route = createFileRoute('/')({
beforeLoad: () => {
throw redirect({ to: '/login' });
},
});export const Route = createFileRoute('/login')({
component: Login,
});When I refresh my browser on "/", I get a blank page. It was working in previous versions. I can provide the entire code later. |
|
I noticed that writing to the context of one route will now overwrite the context of all routes, so the router context is no longer isolated per route. this is confirmed working in v1.36.2 but no longer in v1.36.3, and this release just has this fix, so I think we can trace it back here compare this breadcrumbs example on: |


This PR initially was just to add tests for the route-context checks after navigation, but it became a bit more.
router.navigate(), instead a button is clicked which callsnavigatefromuseNavigate().packages/react-router/tests/redirects.test.tsxrelated to route-context have been REMOVED in favor of the ones inpackages/react-router/tests/routeContext.test.tsxas they simulate real-world usage.I've manually tested these changes against the reproductions in the following issues and can confirm that this PR fixes the following.
Context-related issues still remain broken in this though.
Thanks to @freshgiammi pointing out the unnecessary
this.load().