component did unmount in react js code example
Example 1: componentDidUpdate
componentDidUpdate(prevProps, prevState) {
if (prevState.pokemons !== this.state.pokemons) {
console.log('pokemons state has changed.')
}
}
Example 2: react.component
class Welcome extends React.Component {
render() {
return <h1>Hello, {this.props.name}</h1>;
}
}