Is there a way to pass props from the Parent component down to the Child component using react-router?
<Route path="/parent/" component={Parent} />
<Route path="/parent/child/" component={Child} />
Notice Child is not rendered in the Parent's render function.
Thanks
I think a good solution here would be nested routes with render props.
// Parent.jsx
render() {
const { match: { url }, xyz } = this.props;
return (
<Route path={`${url}/child`} render={() => <Child xyz={xyz} />}
);
}
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.