Skip unchanged class updates
Optimizing an existing class component whose parent re-renders often.
React 19+ · Class
PureComponent is a React class base that shallowly compares props and state to skip unnecessary re-renders. It supports the Component APIs but is mainly intended for existing class components, since new code should generally use functions.
PureComponent is a Component subclass for class components that shallowly compares props and state before updating. React can skip the class component's re-render when those values are unchanged, while context changes can still cause a re-render.
class MyComponent extends PureComponent { render() { return ...; } }A React class component base class; subclasses render their UI through the Component APIs.
import { PureComponent } from 'react';
class Greeting extends PureComponent<{ name: string }> {
render() {
return <h1>Hello, {this.props.name}!</h1>;
}
}
export default function App() {
return <Greeting name="Ada" />;
}This class skips its own re-render when its props and state are shallowly unchanged.
Optimizing an existing class component whose parent re-renders often.
Rendering immutable props and state where shallow comparison reliably reflects meaningful changes.
Migrating or maintaining legacy class-based React code.
ComponentshouldComponentUpdate