【发布时间】:2020-01-23 16:22:51
【问题描述】:
仅供参考,我使用的是 react-router 3.0.0 版。
目前,我正在添加一个父路由组件,它充当包裹在子组件周围的页脚。虽然父组件将正确呈现,但我不断收到错误 Warning: Failed prop type: The prop `children` is undefined 并且没有子组件呈现。我的路线目前看起来像:
export default(store) => {
return [
<Route
path=""
component={Footer}
>
<Route
path="main/intro"
component={Intro}
/>
<Route
path="main/payments"
component={Payments}
/>
</Route>,
]
}
而Footer父组件看起来像
export function Footer({ children }) {
return (
<div>
{children}
<div className={divStyle}>
<OpenEmail />
</div>
<div className={divStyle}>
<Menu />
</div>
</div>
);
}
似乎不应该使用任何高于 v4 的 react-router 版本,嵌套,但我不知道为什么我在低于 v4 的版本中遇到此错误
【问题讨论】:
-
路由有渲染方法
标签: javascript reactjs react-router