admin管理员组

文章数量:1323722

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 badges
Add a ment  | 

1 Answer 1

Reset to default 9

The 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