-
So i have multiple filters i wanna apply, like search, id, team etc that use different kinds of input. What i have been trying to do is that i use a useState hook as the base object where i dynamically add a new property every time i pass in a value to a filter then i use an useEffect hook to sort through that object and check for the newest added property and pass the single property through the useQueryState hook to make it appear on the url. But this way seem to be kinda unstable at times. Removal of the said object also becomes an hassle, is there any better way to go about this ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Ask yourself if those filters all belong under the same key in the URL, or if they can live each on a given key. This decision shouldn't be based on how the implementation works to obtain and apply those filters, but rather on the semantics of each search param in the URL. Eg: prefer You could then recompose them to the right data shape, using |
Beta Was this translation helpful? Give feedback.
Thank you so much, I've found a way to fix my issue.