Answer the question
In order to leave comments, you need to log in
Should I switch to React.PureComponent by default?
Now I usually use React.Component + redux + reselect in the code (a lot of places) to ensure that only changing is rendered. Maybe I forgot and I need to use React.PureComponent everywhere? Although it seems like there is no deep check of shouldupdate going on. where is wrong?
Answer the question
In order to leave comments, you need to log in
React.PureComponent implements the shouldComponentUpdate method in such a way that it does a shallow comparison of props and state (not a deep one). Here is the actual code:
https://github.com/facebook/react/blob/c8fbdac2271...
shouldUpdate =
!shallowEqual(prevProps, nextProps) ||
!shallowEqual(inst.state, nextState);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question