How to get the path of the current route of the React-router-dom with the same parameters and just update the route?

Asked

Viewed 38 times

0

I’m developing a dropdown, and each dropdown item will have a link to redirect to the same page, which will change are the parameters on it.

I want to know how to get the full URL already with the parameters that were used in other dropdown and update the same parameter if applicable.

Example:

/caminho?parametro1=carro

/caminho?parametro2=azul

/caminho?parametro1=carro&parametro2=azul

/caminho?parametro1=carro&parametro2=azul&parametro3=grande

/caminho?parametro1=carro&parametro2=azul&parametro3=pequeno

I want to keep the URL that is already with the previous parameters and just add one more parameter to it and, if the dropdown is used again, it updates the value of the same parameter.

What I’ve done has been so far:

<Linked
  to={{
  pathname: '/caminho',
  search: `?parametro3=${option}`,
}}>
  {option}
</Linked>
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.