pass data from router to component react code example
Example 1: react router how to send data
props.history.push('/other-page', { id: 7, color: 'green' }))
Then, you can access the state data in '/other-page' via:
props.location.state
Example 2: passing data in route react
<Route path="/" render={() => <Search name={this.props.name} />} />
Example 3: passing data in route react
<Route path="/" component={() => <Search name={this.props.name} />} />
Example 4: can I pass function as prop on route change
<Link to={{
pathname: '/Content/' + this.props.index
state: {decrease: this.props.decreaseIndexProject}
}}>Page n°1</Link>
<Router>
<Switch>
<Route path="/Content/:index" exact name="content" component={Content} />
</Switch>
</Router>