React.Component vs React.PureComponent [closed]

The official React docs state that “React.PureComponent‘s shouldComponentUpdate() only shallowly compares the objects”, and advises against this if state is “deep”.

Given this, is there any reason why one should prefer React.PureComponent when creating React components?

Questions:

  • is there any performance impact in using React.Component that we may consider going for React.PureComponent?
  • I am guessing shouldComponentUpdate() of PureComponent performs only shallow comparisons. If this is the case, can’t said method be used for deeper comparisons?
  • “Furthermore, React.PureComponent‘s shouldComponentUpdate() skips prop updates for the whole component subtree” – Does this mean that prop changes are ignored?

Question arose from reading into this medium blog, if it helps.

4 Answers
4

Leave a Comment