2018-04-06 14:40:48 -04:00
|
|
|
# React-Lifecycle-Cheatsheet
|
|
|
|
|
2018-04-06 14:50:21 -04:00
|
|
|
Short reference of React.Component lifecycle methods so I don't have to scroll through the huge text on the official documentation
|
|
|
|
|
|
|
|
![Lifecycle Diagram](./Lifecycle-chart.jpg)
|
|
|
|
|
|
|
|
## Mounting
|
|
|
|
|
|
|
|
### constructor ()
|
|
|
|
|
|
|
|
```
|
|
|
|
/**
|
|
|
|
* Create state and call super
|
|
|
|
*
|
|
|
|
* @param {object} props
|
|
|
|
*/
|
|
|
|
constructor (props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
foo: 'bar'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### static getDerivedStateFromProps ()
|
|
|
|
|
|
|
|
## Updating
|
|
|
|
|
|
|
|
### shouldComponentUpdate ()
|
|
|
|
|
|
|
|
## Unmounting
|
|
|
|
|
|
|
|
### componentWillUnmount ()
|