I want a component which renders on every route, and has child components (e.g. a header).
By leaving out exact in the route I can achieve that.
render(
<Router>
<Route path="/" component={App}/>
</Router>,
document.getElementById('app')
);
Inside the component, I have nested routes:
const App = ({match}) => (
<Switch>
<Route path={`${match.url}login`} component={LoginForm}/>
<Route path={`${match.url}panel`} component={ControlPanel}/>
</Switch>
);
It picks one out of two components to render, based on the path.
As shown in the documentation we need to use the match url. This was very confusing to me, since the match.url is /, and blindly following the examples I wrote e.g. '{${match.url}/login}', which results in //login
`
My question: if I do not match a parameter, why can't I use a full path in the child?
The following does not work when used inside App:
<Route path="/login" component={LoginForm}/>
${match.url}login} is equivalent to path="/login" but the latter does not work?