Hi all I am new to ES6 and React and I am stuck in component lifecycle-creation of react. My question is In my constructor I have initialized state..
constructor(props) {
super(props);
this.state = {
....something
}
Now in the Component Lifecycle Creation in react we have getDerivedStateFromProps which is a static function which takes two arguments props and previous state and you might return the current state or so depending if you are changing the state from props or not
static getDerivedStateFromProps (props, state) {
... do something
return state;
}
How is this static function able to access or have a property which is initialized in constructor() which will run at runtime or when the object is created ? Isn't the static function runs before runtime at class loading time so how is it able to access state object ?