我是一个redux初学者,并坚持通过redux道具来路由渲染问题 .
×
TypeError: Cannot read property 'quantity' of undefined
PageLayout._this.render
src/components/controls/PageLayoutRoute/PageLayoutRoute.js:135
132 | to: routes.checkout,
133 | withArrow: true,
134 | bold: true,
> 135 | disabled: (this.props.nonFrameDisplay.quantity == 0 && this.props.frameDisplay.quantity == 0) ? true : false
136 | };
137 | }
138 |
PageLayoutRoute看起来像这样 .
const PageLayoutRoute = ({component: Component, ...rest }) => {
return (
<Route
{...rest}
render={props =>
<PageLayout {...props}>
<Component />
</PageLayout>}
/>
)
};
PageLayoutRoute.propTypes = {
component: PropTypes.func.isRequired,
};
const mapStateToProps = state => ({
nonFrameDisplay: state.app.nonFrameDisplay,
frameDisplay: state.app.frameDisplay,
});
const mapDispatchToProps = {
};
export default withRouter(connect(mapStateToProps, mapDispatchToProps)(PageLayoutRoute));
PageLayout组件包含在PageLayoutRout中 . 看起来像这样 .
class PageLayout extends React.Component {
static propTypes = {
children: PropTypes.node.isRequired,
hideTopNav: PropTypes.bool,
hideBottomNav: PropTypes.bool,
...bottomNavProps
};
static defaultProps = {
hideTopNav: false,
hideBottomNav: false
};
如何通过使用react-router-dom的路由渲染从redux存储传递nonFrameDisplay,FrameDisplay道具?提前致谢!
1 回答
当你写作
将
PageLayoutRoute
连接到Store后收到的道具将传递给Route组件但是这些都没有传递给Route渲染的Component,
你需要做点什么