<Route path="/users/:userId" component={UserShow}>
<Route path="/location/:locationId" component={LocationShow} />
</Route>
I see this warning in my chrome console:
bundle.js:887 Warning: You should not use <Route component> and <Route children> in the same route; <Route children> will be ignored
If I shouldn't add a component to the /user/:userId route, where am I suppose to add the component UserShow then?
Nested routes should be added to the parent component directly:
const UserShow = props => (
<div>
<div>User info</div>
<Route path={`${props.match.url}/location/:locationId`} component={LocationShow} />
</div>
);
<Route path="/users/:userId" component={UserShow} />
LocationShow
will only be rendered when the path matches /users/:userId/location/:locationId
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.