How to add / remove multiple parameters from the route in react?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



How to add / remove multiple parameters from the route in react?



I have a route like so:


http://www.website.com/products/



Now I have filter buttons on the page e.g. Dress, Shirts, Hats


Dress, Shirts, Hats



I am using qs to parse the URL so that the filters change based on the route parameters e.g.:


http://www.website.com/products/?filter=dress&filter=hats



That is, if I manually type those parameters in the URL. However, what I'd like to happen is when the user clicks on the filter, the route will change to whatever filter is clicked on. So far I am using history.push like so:


history.push


queryURL(filter)
this.props.history.push(
pathname: "/products/",
search: `?filter=$filter`
);



But this is only changing the filter one at time. I'd like to be able to keep adding into the filter parameter if I click on more filters (resulting to the route with 2 (or more) filters I showed above).



How do I achieve this?









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard