-
-
Notifications
You must be signed in to change notification settings - Fork 593
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(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 <16855748+freshgiammi@users.noreply.github.com>
@@ -1548,7 +1548,7 @@ export class Router< | |||
redirect = err | |||
if (!this.isServer) { | |||
this.navigate({ ...err, replace: true, __isRedirect: true }) | |||
this.load() | |||
// this.load() |
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.
The fix pointed out by @freshgiammi.
@@ -463,88 +459,3 @@ describe('router.navigate navigation using layout routes resolves correctly', as | |||
expect(router.state.location.pathname).toBe('/g/tkdodo') | |||
}) | |||
}) | |||
|
|||
function createContextRouter<TCtx extends Record<string, unknown>>( |
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.
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 callsnavigate
fromuseNavigate()
.packages/react-router/tests/redirects.test.tsx
related to route-context have been REMOVED in favor of the ones inpackages/react-router/tests/routeContext.test.tsx
as 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()
.