Class components and migration

shouldComponentUpdate

Optional performance decision based on next props and state; must not be relied on for correctness.

Formal Syntax & Structure

react syntaxreact
shouldComponentUpdate(nextProps, nextState) { return nextProps.name !== this.props.name || nextState.count !== this.state.count; }

Working Example

Example Snippetreact
shouldComponentUpdate(nextProps, nextState) { return nextProps.name !== this.props.name || nextState.count !== this.state.count; }
React Reference