-
-
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
[v5] Not compatible with React 18 StrictMode #7870
Comments
Tested with v6, seems OK |
I had the same issue. It's not working when used in |
Yes. Same |
In my case, updating to version 6 is impossible, because there is no way to control history outside of react |
Just to clarify the issue: with React 18 StrictMode, react-router does not perform the transition when navigation occurs. The route is stale when the path is changed: https://codesandbox.io/s/dreamy-andras-hbuco1?file=/src/index.tsx The behavior occurs in v5.3.0 too. As React 18 is officially released and the StrictMode is preferred in many cases as default in a development environment, this issue should become more relevant. As there is still no backwards compatibility package, can we expect the patch release of v5 for the issue? |
If someone wants to make a PR, I'd be happy to do a patch release for v5. |
It is not working if BrowserRouter is a child of StrictMode. So, to make it work we can put StrictMode as child of BrowserRouter. |
I think I've got a fix for this in #8831 |
This solves it BUT we are experiencing mout-unmounts-mount cycles for each component. This rerender behaviour is solved when removing the strictmode. |
Following this issue: https://stackoverflow.com/a/71833424/8690857 |
Description: update to createRoot, update dependencies to new versions that work with v18 (xstate/testing lib), tailwind no longer needs postcss compat so removed craco, update tailwind config to new format + flex-grow > grow, CURRENT ISSUE, react-router5 has issues with new strict mode remix-run/react-router#7870
* update to react 18, update tailwind, remove craco Description: update to createRoot, update dependencies to new versions that work with v18 (xstate/testing lib), tailwind no longer needs postcss compat so removed craco, update tailwind config to new format + flex-grow > grow, CURRENT ISSUE, react-router5 has issues with new strict mode remix-run/react-router#7870 * add server validation for string ids * refactor to new react-router syntax * update react router * audit fix * update markdown packages, needed to add setting to run tests because of jest /module support wonky * update markdown packages, needed to add setting to run tests because of jest /module support wonky * typos in versus path * fix passing RequireRole element instead of child * (fix) sign out was broken on fast connection because redirect happened before request completed * (chore) update joi * (chore) update xstate * (chore) update react-query
Thanks for the help |
Omg big thanks. I was so stressed out for few days cause of it |
This comment has been minimized.
This comment has been minimized.
The problem seems a little bit complicated for this approach because the issue also appears in the component, so StrictMode would be wrapping the routes. |
Version
v5.2.0
React 18 with StrictMode, see reactwg/react-18#19
Test Case
https://codesandbox.io/s/react-router-forked-1s3zi
Steps to reproduce
Click around
Expected Behavior
Works
Actual Behavior
Not working
The text was updated successfully, but these errors were encountered: