1

I have a React - Redux - React Router v4 application in which the URL looks something like this:

www.mysite.com/:accountName/brands/:brandId/something
www.mysite.com/:accountName/brands/:brandId/somethingElse

An actual example would be:

www.mysite.com/sears/brands/levis/jobs

In my global navigation menu, I have a Brand Select dropdown menu where I can switch the selected brand via. brandId. The idea is to keep the rest of the URL untouched and just change the brandId param.

So when the new brand URL is clicked, the updated URL should be: www.mysite.com/sears/brands/wrangler/jobs

One approach I thought of was to use a RegEx to replace the path, but that seems like an imperative approach.

Is there a native way in React Router v4 to achieve this?

nikjohn
  • 16,079
  • 9
  • 45
  • 78
  • build Parent react component and initialize state with those params and have render method with ROUTE component binded as follows. "" – Karun Sep 25 '18 at 07:02
  • I think there's been an answer for the question you are asking here: https://stackoverflow.com/questions/44141025/react-update-url-base-on-action, basically you can just replace the current params in the url with a new one. – Thai Duong Tran Sep 25 '18 at 07:27

0 Answers0