-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Description
Reproduction
-
react-router@7.7.0: https://codesandbox.io/p/devbox/react-router-7-7-0-usesearchparams-prev-setter-vnjtfr -
react-router@7.6.3: https://codesandbox.io/p/devbox/react-router-7-6-3-usesearchparams-prev-setter-forked-dxrkl5
Change anything in the input text field. In 7.6.3 this automatically updated the search params. Updates to the search params (e.g., initial page load or otherwise) would then automatically be used to set the input text field value.
React.useEffect was used to (a) update the URLSearchParams when an input text field changes and (b) changes of URLSearchParams were observed to updated the same input text field. This was used to generate perma URLs that reflect the input form fields, so users can change the text input field and the URL is up to date and others users can paste the perma URL and have already pre-filled forms.
In react-router version 7.6.3 everything worked as intended. With version 7.7.0 this behaviour changed, probably due to #12784 where the setSearchParams hook receives a copy of the last searchParams which might cause the detection whether something changed to be different.
System Info
System:
OS: Linux 6.1 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
CPU: (2) x64 AMD EPYC
Memory: 2.55 GB / 4.01 GB
Container: Yes
Shell: Unknown
Binaries:
Node: 20.12.0 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.5.0 - /usr/local/bin/npm
pnpm: 8.15.6 - /usr/local/share/npm-global/bin/pnpm
npmPackages:
react-router: 7.7.0 => 7.7.0
vite: ^6.0.3 => 6.0.3Used Package Manager
pnpm
Expected Behavior
Input field works without issues and changes are possible.
Actual Behavior
Input text field can't be changed.