Add a useSearchParam
hook which returns a handle for reading/updating indvidual query params
#11174
Closed
pyramid-scheme-ceo
started this conversation in
Proposals
Replies: 2 comments
-
Fyi did some more work - here's the implementation with a bit more of a focus on extensibility now:
...And some examples where I've started implementing it in an app:
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Closing in favour of #11180 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I know I can't be the only one who doesn't particularly love the approach for updating query params in react-router at the moment, so I'm proposing a
useSearchParam
hook which returns an accessor for a single search param at a time.The value of the property is read and updated through the
.current
property. Implementation-wise, it is essentially a wrapper around the existinguseSearchParams
hook.Note:
This is my first contribution to this repository, so just writing up this proposal first to see if it's useful and would potentially be included before going into more effort with the actual implementation, tests, PR, etc.
Example usage:
Work-in-progress implementation:
Beta Was this translation helpful? Give feedback.
All reactions