-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Closed
Labels
Description
What version of React Router are you using?
6.8.0
Steps to Reproduce
I've created 2 examples, one that is working (version I've reverted to) and the latest, where it is now broken.
Working (v6.6.2): https://stackblitz.com/edit/react-ts-9g8mr3?file=App.tsx
Broken (v6.8.0): https://stackblitz.com/edit/react-ts-9gbuje?file=App.tsx
- Create a brand new project
- Install the latest version of react-router-dom (time of writing v6.8.0)
- In App.tsx add the following:
import * as React from 'react';
import './style.css';
import {
RouterProvider,
createMemoryRouter,
Link,
redirect,
Form
} from 'react-router-dom';
const router = createMemoryRouter(
[
{
path: '/first',
element: <section>
<Link to="/throw">Throw Redirect</Link>
<Form method="post" action="/throw">
<button type="submit">Post to throw</button>
</Form>
</section>
},
{
path: "/redirect",
element: <section><p>I see you have found your way here :(</p><Link to="/first">Back to First</Link></section>
},
{
path: '/throw',
loader: () => {
throw redirect('/redirect');
},
action: () => {
throw redirect('/redirect');
},
},
],
{
initialEntries: ['/first'],
initialIndex: 0,
}
);
export default function App() {
return (
<RouterProvider router={router} fallbackElement={<p>Nothing here!</p>} />
);
}
- Once the page is loaded, click Link
Throw Redirectand notice the actual URL in the browser has been updated.
Expected Behavior
Like in v6.6.2, the URL should not update when using the memory router option.
Actual Behavior
The current behaviour is the URL is being updated with the thrown path.