static getDerivedStateFromProps code example

Example 1: lifecycle method react

INITIALIZATION= setup props and state 
MOUNTING= constructor->componentWillMount->render->componentDidMount//Birth
UPDATE= shouldComponentUpdate->componentWillUpdate->render
  		->componentDidUpdate //Growth
UNMOUNTING= componentWillUnmount //Death

Example 2: component did mmount

componentDidMount()

Example 3: component did mmount

componentDidUpdate(prevProps, prevState, snapshot)

Example 4: react lifecycle

constructor(props) {
  super(props);
  // Don't call this.setState() here!
  this.state = { counter: 0 };
  this.handleClick = this.handleClick.bind(this);
}

Tags:

Misc Example