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
When a component updates search params using useSearchParams, all the other components that consume useSearchParams should get the updated value at the same time as the component triggering the change.
Actual Behavior
When setSearchParams is called with an updater function as argument; if this function directly mutates the current URLSearchParams passed to it and returns that, the calling component will get the updated search params value on the first re-render. But the other components that use useSearchParams will get the updated value on the third re-render.
The text was updated successfully, but these errors were encountered:
hasanayan
changed the title
Updates to search params using useSearchParams are not always propagated at the same time to all consumers
Updates to search params using useSearchParams are not always propagated at the same time to all consumers
May 30, 2024
Reproduction
https://stackblitz.com/edit/remix-run-remix-8wtcgn?file=app%2Froutes%2F_index.tsx
To reproduce;
set param mutate current
button on any of the componentsTo see how it behaves without mutating the passed in current search params;
set param (create new URLSearchParams)
on any of the componentsSystem Info
Used Package Manager
pnpm
Expected Behavior
When a component updates search params using
useSearchParams
, all the other components that consumeuseSearchParams
should get the updated value at the same time as the component triggering the change.Actual Behavior
When
setSearchParams
is called with an updater function as argument; if this function directly mutates the currentURLSearchParams
passed to it and returns that, the calling component will get the updated search params value on the first re-render. But the other components that useuseSearchParams
will get the updated value on the third re-render.The text was updated successfully, but these errors were encountered: