I am trying to find documentation from the react router website https://reacttraining.com/react-router, and I cant seem to find a solution to have nested routes work in 4.1.1. For example in the older version of React Router, you would be able to nest Routes like so:
<Router history={history}>
<Route exact path="/" component={App}>
<Route path="/cards" component={Example} />
</Route>
</Router>
This used the {this.props.children} and made it easy to have static components such as a navbar exist all through the application without having to import it in every component.
class App extends Component {
render() {
return (
<div>
<Header/>
<main>{ this.props.children }</main>
<Footer/>
</div>
);
}
}
How can I have similar behavior with version 4.1.1. I do not want to import the header component all the time in the components.
I am using at the moment, but it does not seem to accomplish what I am trying to do.
<Router history={history}>
<Switch>
<Route exact path="/" component={App}>
<Route path="/cards" component={Example} />
</Route>
</Switch>
</Router>