You get a bonus - 1 coin for daily activity. Now you have 1 coin

What is the purpose of the getDerivedStateFromProps() lifecycle method? in REACT

Practice



The new static

getDerivedStateFromProps()
lifecycle method is called after a component instance is created and also before it is re-rendered. It can return an object to update state, or
null
to indicate that the new props do not require any state updates.
class MyComponent extends React.Component {
  static getDerivedStateFromProps(props, state) {
    // ...
  }
}
This lifecycle method, together with componentDidUpdate()
covers all the use cases of componentWillReceiveProps()

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Scripting client side JavaScript, jqvery, BackBone"

Terms: Scripting client side JavaScript, jqvery, BackBone