1

I have to selects that trigger the next functions:

const firstQuery = (value) => {
  history.replace(`${match.path}cars/?car=${value}`);
};

const secondQuery = (value) => {
  history.replace(`${match.path}cars/?color=${value}`);
};

When i trigger the first function the url is changing ok: my-site/cars/?car=audi, but when i trigger the second one it reset the first value of ?car=audi and i get my-site/cars/?color=red, but my expectation is to get something like: my-site/cars/?car=audi&color=red
How to fix this and to get what i expect?

1 Answer 1

1

history.replace, replace whole url so you must set your url complete in that

const secondQuery = (value1,value2) => {
  history.replace(`${match.path}cars?car=${value1}&color=${value2}`);
};

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.