javascript - Get the path of a certain Route in react-router -
using react-router in react have declared routes this:
<route name="voteview" path="voteview/:baselineid" handler={voteview}/>
in react component, want call route. react router gives me link:
<link to="voteview" params={{baselineid: this.props.data.baselineid}}>voteview</link>
this results in <a href...>
link.
but want use url path programmatically, not in <a href...>
link. how can url path "voteview" route programmatically?
you can use makehref
method on react routers context generate path this:
this.context.router.makehref('voteview', {baselineid: this.props.data.baselineid})
Comments
Post a Comment