Decide about replace or push state inside callback #14045
dt-mkuster
started this conversation in
Proposals
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Problem Description
Currently, with the
setSearchParams
API, I cannot dynamically decide whether to replace or push a history entry based on the difference between the previous state and the new state.For example:
The replace option is passed outside the callback, making it impossible to compute dynamically based on changes between prev and next.
Proposed Solution
Allow the replace option to be decided dynamically, either by:
Allowing the callback to return both next and replace:
Making replace a callback that receives prev and next:
Why This Matters
This would simplify handling cases like:
Replacing history for incremental updates (e.g., typing in an input).
Pushing history for significant changes (e.g., dropdown selection).
Let me know if you'd like more details!
Beta Was this translation helpful? Give feedback.
All reactions