-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
React Router v7 library mode with createBrowserRouter
doesn't re-render on file changes in Vite HMR
#13159
Comments
createBrowserRouter
cause Vite HMR not workingcreateBrowserRouter
doesn't re-render on file changes in Vite HMR
Thanks for narrowing down the version that caused the issue. Looks like this issue was introduced in this PR: #12800 Seems like it's because the app is re-rendering with a new @brophdawg11 Do you have any thoughts on how best to support HMR here? |
We have the same problem but in a completely different use case. In our tests with Vitest + Testing Library we render our component that we want to test and specify a wrapper component that creates a memory router and renders the router provider. Then we call const TestingRoutingProvider = ({ children }) => {
const router = createMemoryRouter([
{
index: true,
element: children,
},
]),
);
return <RouterProvider router={router} />;
};
// In our test
const { rerender } = render(
<SomeComponent value="foo" />,
{ wrapper: TestingRoutingProvider },
);
rerender(<SomeComponent value="bar" />); |
@alanko0511 @rothsandro Hello, I experienced same issue after migration from remix to react-router 7. I use file naming convention and awaiting "flatRoutes" helped me to solve HMR issues. Here is the code from docs:
|
My application is running into the exact same issue that @rothsandro outlined. |
I'm using React Router as a...
library
Reproduction
https://stackblitz.com/edit/vitejs-vite-ry7qt74n?file=src%2Froutes%2FIndexPage.tsx
Change the
div
text in thesrc/routes/IndexPage.tsx
file, the page doesn't re-render. However, if I downgrade the React Router package version to 7.1.3, it will re-render as expected.I saw that the Vite HMR WebSocket receives the file changes and downloads the file correctly when I test it locally, so I believe Vite is working as expected.
System Info
Used Package Manager
pnpm
Expected Behavior
The page should be re-rendered when I change an element in the demo's
src/routes/IndexPage.tsx
file.Actual Behavior
The changes I made don't cause it to re-render.
The text was updated successfully, but these errors were encountered: