0
如果我有我的路由器以下:React-Router:除了props.children,我可以传递额外的变量给父母吗?
<Route path="/" component={MainLayout}>
<Route path="path/one" component={App1} hasTitle={false} />
<Route path="path/two" component={App2} hasTitle={true} />
</Route>
我会在MainLayout
得到任何App1
或App2
为this.props.children
。但是我可以通过在子路线中传递hasTitle=false
或hasTitle=true
来获得MainLayout中的其他一些定制吗?
传递额外的道具下到孩子,而不是
{this.props.children}
,如果你想从路线的道具,你可以用这个,props.route.hasTitle –