constructor method in react code example
Example 1: constructor react
constructor(props) {
super(props);
// Don't call this.setState() here!
this.state = { counter: 0 };
this.handleClick = this.handleClick.bind(this);
}
Example 2: component did mmount
componentDidUpdate(prevProps, prevState, snapshot)