I want to use URL paths for my app. Currently I just render a Main
component in app.js
:
render() {
return (
<Main
isLoggedIn={this.state.isLoggedIn}
user={this.state.user}
... />
)
}
(The props are a bunch of variables and functions)
I tried using react-router but I don't understand how to send props to the child components.
<Router history={browserHistory} >
<Route path='/' component={Main}
... where to send props? />
<Route path='join' component={Join}
... props />
</Router>
The problem is that I need some state variables of my App
component (in app.js
) to be available in both Main
and Join
. How do I achieve that with a router?
App structure:
App
- Join
- Main
- ...