user3588408
user3588408

Reputation: 301

How can i pass parameters on redirection using react router?

I'm using react router version 2.0.1 for navigation between components. I came across a scenario where i want dynamically navigate to other component I did something like this for redirection

browserHistory.push("/some/path");

It is navigating to other component perfectly. But i also want to pass some parameters along with the redirection. I tried doing it like

browserHistory.push("/some/path", {query: "param1"});
browserHistory.push("/some/path", {query: {param1: value1}});

But when i try to fetch the value from this.props.location it shows blank query result.

Any suggestions would be greatly appreciated.

Upvotes: 4

Views: 4791

Answers (1)

Gjoshevski
Gjoshevski

Reputation: 149

This shuld work for you:

router.push({
  pathname: '/some/path',
  query: { param1: value1 } 
})

or I've seen people doing this and looks like its workin ok:

browserHistory.push("/some/path?param1=value1");

Upvotes: 4

Related Questions