-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
[Bug]: Navigate malfunction in createBrowserRouter #10417
Comments
The code was working as expected in v6.10.0 |
same bug, only in the development env |
My code earlier.
Working earlier but now I have to
|
@huijiewei Yes this issue is in dev env and upon inspection I realize it is occurring due to StrictMode. |
Yeah this is definitely due to The usage of I would argue that this is sort of "working as React expects" in that when you use The idiomatic way to do this with {
index: true,
loader: () => redirect("profile"),
}, I'll dig in a bit deeper but I'm not sure if there's much we can do about this unfortunately since we don't have visibility into the pending async state in the second navigate 😕 . |
This is actually also breaking any call to Navigate in my app as well. This works fine in 6.10.0 but completely breaks in 6.11.0. The problem is compounded with a dynamic portion in the path. Take the following code: <Route
path=":username"
element={<Suspend child={<PatientContainer />} />}
errorElement={<ErrorDisplayBoundary />}
>
<Route index element={<Navigate to="overview" replace />} />
<Route
path="overview"
element={<Suspend child={<Overview />} />}
errorElement={<ErrorDisplayBoundary />}
/>
</Route> In 6.10.0, if you landed on Same goes for anywhere else that I have a Navigate component. return createBrowserRouter([
{
path: '/',
element: <Index />,
errorElement: <ErrorDisplayBoundary />,
children: [
{
index: true,
element: <Navigate to="/reporting" replace />,
},
{
path: 'census/*',
element: <Navigate to="/members" replace />,
}, These two routes redirected correctly, from |
@reintroducing Is there a specific reason you're using |
@brophdawg11 Yes, they were migration from |
Thanks for clarifying @reintroducing. In a mixed app - you can use loaders on any routes defined via But you are correct that any We should be getting a prerelease out soon with these fixes that you can test out 👍 |
🤖 Hello there, We just published version Thanks! |
@brophdawg11 i just tested |
🤖 Hello there, We just published version Thanks! |
What version of React Router are you using?
v6.11.0
Steps to Reproduce
Check this repo https://stackblitz.com/edit/react-ts-ffc4fk?file=App.tsx
Expected Behavior
When I go to
dashboard
route it should route to/dashboard/profile
Actual Behavior
it is routing to
/dashboard/profile/profile
The text was updated successfully, but these errors were encountered: