admin管理员组文章数量:1323373
What's the difference between pure() from the Repose library and React.PureComponent? I'm guessing they are essentially solving the same problem. Can someone please clarify this?
What's the difference between pure() from the Repose library and React.PureComponent? I'm guessing they are essentially solving the same problem. Can someone please clarify this?
Share Improve this question asked Sep 28, 2018 at 1:10 avatarhzhavatarhzh 2,3935 gold badges24 silver badges36 bronze badges1 Answer
Reset to default 9The difference is that React.PureComponent
is stateful ponent and keeps track on the state:
React.PureComponent is similar to React.Component. The difference between them is that React.Component doesn’t implement shouldComponentUpdate(), but React.PureComponent implements it with a shallow prop and state parison.
While Repose is aimed at stateless functional ponents, pure
shallowly detects changes in props only.
Both use shouldComponentUpdate
to shallowly detect changes, so there's no practical difference between them, as long as a ponent doesn't involve local state.
本文标签: javascriptRecompose pure() vs ReactPureComponentStack Overflow
版权声明:本文标题:javascript - Recompose pure() vs React.PureComponent - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742123352a2421825.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论