Reputation: 485
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.js
I use Link
<Link to={{ pathname: "/detail", query: { blogId: this.props.id } }}>Detail</Link>
but it didn't work, how to replace the :blogId
part with state or props?
Upvotes: 4
Views: 660
Reputation: 663
:blogId
is a param, not a query.
You can simply set your param in the link tag like this:
<Link to={'/detail/' + this.props.id}>Detail</Link>
Upvotes: 1