ShouldComponentUpdate()

By default, React will bail out and not re-render a subtree if the old and new subtrees are equivalent. Additionally, in class components, you can control whether to re-render a component and its associated subtree with the shouldComponentUpdate() lifecycle method. A component will be updated only if its state or props have changed, and its shouldComponentUpdate() method returns true. Avoiding unnecessary re-renders with shouldComponentUpdate() can enhance performance.

In function components, the equivalent optimization is to wrap the component with React.memo(), which does a shallow comparison of props (similar to the default behavior shouldComponentUpdate() would otherwise implement) and skips re-rendering when they haven't changed.