componentWillReceiveProps method

  1. @override
  2. @mustCallSuper
void componentWillReceiveProps(
  1. Map nextProps
)
override

ReactJS lifecycle method that is invoked when a Component is receiving newProps.

This method is not called for the initial render.

Use this as an opportunity to react to a prop transition before render is called by updating the state using setState. The old props can be accessed via props.

Calling setState within this function will not trigger an additional render.

See: reactjs.org/docs/react-component.html#updating-componentwillreceiveprops

UNSUPPORTED IN COMPONENT2

This will be completely removed alongside the Component class; switching to Component2.getDerivedStateFromProps is the path forward.

Implementation

@override
@mustCallSuper
void componentWillReceiveProps(Map nextProps) {
  if (inReactDevMode) {
    validateProps(nextProps);
  }
}