We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
我觉得这个貌似强制不太好?因为如果没有办法很方便的判断是否组件需要更新(比如不是immutable无法===),实现shouldComponentUpdate的成本并不低,而且性能收益也不高,不如不实现?
The text was updated successfully, but these errors were encountered:
事实上不用immutable的话react的表现是“未知行为”,因为一个组件是否被走到shouldComponentUpdate这一阶段是非常“不显而易见”的,比如你的任意一个父组件的shouldComponentUpdate返回了false,那么你就没机会判断,比如如果用connect和redux store连接后store的这个值没有变,你也没机会判断
shouldComponentUpdate
false
connect
因此,在组件的state上不使用immutable几乎可以肯定会遇到各种各样的坑,而我以为这边用immutable应该已经是常识,所以没有写进规范中
在immutable已经是常识的前提下,只会在2种情况下不继承PureComponent:
PureComponent
shallowEqual
render
(state, prop) => vdom
再综合上面2点,我认为基本上只会在“有自己更高效的shouldComponentUpdate实现”的情况下才会不继承PureComponent,也希望仅在这种情况下出现这种继承关系
Sorry, something went wrong.
基于用immutable的假设下,这是没问题的。但是,我发现貌似很多产品线并未immutable,特别是未进行状态管理的产品,就是挨个挨个的component在写,这种我们是否需要在style guide中考虑
有没有能作为参考的项目让我看一眼,我思考下这里怎么做取舍吧
No branches or pull requests
我觉得这个貌似强制不太好?因为如果没有办法很方便的判断是否组件需要更新(比如不是immutable无法===),实现shouldComponentUpdate的成本并不低,而且性能收益也不高,不如不实现?
The text was updated successfully, but these errors were encountered: