You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Workaround: avoid prev at all costs. For the maintainers, very likely, mutating prev in any way triggers a change to the underlying data in a code path independent of relying on the path.
Leaving prev untouched and cloning it into an object will trigger the happy path and allow it to work.
// old code
routerSetSearchParams(
(prev) => {
// modify prev, e.g. prev.key = value
return prev;
},
);
// workaround
routerSetSearchParams(
(prev) => {
const next = Object.fromEntries(prev.entries());
// modify next in the same way you would modify prev
return next;
},
);
What version of React Router are you using?
6.27.0
I was able to repro the bug. This is a stackblitz with an environment that allows you to repro. I used 6.27.0
https://stackblitz.com/edit/github-ypgwe9?file=src%2Fapp.tsx,src%2Fmain.tsx
I've attached two videos explaining the bug as well:
Screen.Recording.2024-11-08.at.4.31.41.PM.mov
setSearchParams
functionScreen.Recording.2024-11-08.at.4.32.21.PM.mov
The text was updated successfully, but these errors were encountered: