如果状态不变,为什么react-redux会重新渲染组件?

时间:2017-10-21 08:34:30

标签: javascript reactjs redux react-redux

我有在grammar Verb { token TOP { <root> <ending> } token root { (\w+) <?{ ~$0 (elem) @root }> } token ending { (\w+) <?{ ~$0 (elem) @ending }> } } my @root = <go jump play>; my @ending = <ing es s ed>; my $string = "going"; my $match = Verb.parse($string); .Str.say for $match<root>; 订阅的组件:

auth

当我在嵌套组件中更改存储时,RequireAuthComponent也会重新渲染,但export default function requireAuthComponent(Component, redirectTo = '/') { class RequireAuthComponent extends React.Component { shouldComponentUpdate(nextProps) { return nextProps.auth.logged !== this.props.auth.logged; } render() { const { auth } = this.props; if (auth.logged) { return <Component {...this.props} />; } return <Redirect to={redirectTo} />; } } return connect(({ auth }) => ({ auth }))(RequireAuthComponent); } 存储没有更改,但如果我在auth中添加了比较auth存储,则它可以正常工作。为什么redux不会比较componentShouldUpdate自己存储,在文档中说react-redux比较存储和重新渲染组件,如果在mapStateToProps中传递的旧商店和新商店不相等?

auth

0 个答案:

没有答案