Update State Based on Props using the Lifecycle Hook getDerivedStateFromProps in React16.3

InstructorNik Graf

Share this video with your friends

Send Tweet

getDerivedStateFromProps is lifecycle hook introduced with React 16.3 and intended as a replacement for componentWillReceiveProps. It is invoked after a component is instantiated as well as when it receives new props. It should return an object to update state, or null to indicate that the new props do not require any state updates.