Answer the question
In order to leave comments, you need to log in
How to check for adding URL query params react-router-dom?
How to add new query params to URL string?
I have 4 types of query params, and I need them to be added one after the other when clicked, without ?
, if it is already there at the beginning.
<p onClick={() => history.push('?sortBy=ASC')}>Featured</p>
<br />
<p onClick={() => history.push('?sortBy=DESC')}>Newest</p>
<br />
<p onClick={() => history.push('?color=black')}>Black</p>
<br />
<p onClick={() => history.push('?color=blue')}>Blue</p>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question