Skip to content
doubtly

2 answers

A pure component (React.PureComponent) re-renders only when its props or state actually change, found by a shallow comparison.

class Greeting extends React.PureComponent {
  render() { return <h1>Hello {this.props.name}</h1>; }
}

// function-component equivalent
const Greeting2 = React.memo(function ({ name }) {
  return <h1>Hello {name}</h1>;
});
  • PureComponent implements shouldComponentUpdate() for you: it compares old and new props and state shallowly and skips render() if nothing changed. This improves performance by avoiding unnecessary re-renders.
  • A normal React.Component re-renders whenever its parent re-renders or setState is called.
  • Because the comparison is shallow, mutating an object or array in place will not be detected; always create a new object or array when updating.
Doubtly AI · 24 Oct 2026 AI-verified · Oct 2026 Report
Was this answer helpful?

Your answer

Log in or create a free account to answer this question.