How to transfer state via a link to a reaction router

I use a router like this:

render((
  <Router history={browserHistory}>
    <Route path="/" component={App}>
      <IndexRoute component={Home}/>
      <Route path="/detail/:blogId" component={DetailView}/>
    </Route>
  </Router>
), document.getElementById('app'))

and in blog.jsi useLink

<Link to={{ pathname: "/detail", query: { blogId: this.props.id } }}>Detail</Link>

but it didn’t work, how to replace a part :blogIdwith a condition or props?

+4
source share
2 answers

:blogId is a parameter, not a query.

You can simply set your parameter in the link tag as follows:

<Link to={'/detail/' + this.props.id}>Detail</Link>
+1
source

Just write Var link = "detail /" + this.props.id;

Detail

0
source

All Articles