7

In my routes I have

<Route>
    <Redirect from="/" to="/view/something"/>
    ...
</Route>

But if I hit the root url with rooturl/?query=somequery I lose the query paremeter after the redirect. How can I preserve all query parameters after redirect?

roscioli
  • 1,200
  • 3
  • 15
  • 33
  • My solutions for: - [react-router v3](https://stackoverflow.com/a/44057800/746347); - [react-router v4](https://stackoverflow.com/a/56823112/746347). – mixel Jun 30 '19 at 07:22

1 Answers1

-2

I hope it will help: https://github.com/rackt/react-router/issues/1034

Here you can specify and reuse your existing query params after redirect like this:

<Redirect from="/foo/:id" to="/bar/:id"/> (id will be reused).

Also you might want to have some hooks right before/after transition is actually done for some kind of routing management. It's possible to do with onEnter and onLeave hooks. You can read about it in official docs.

oleh.meleshko
  • 4,675
  • 2
  • 27
  • 40