Add more methods, flesh out getDerivedStateFromProps

This commit is contained in:
Timothy Warren 2018-04-06 15:01:51 -04:00
parent f077346449
commit ac10319fd5

View File

@ -6,7 +6,7 @@ Short reference of React.Component lifecycle methods so I don't have to scroll t
## Mounting ## Mounting
### constructor () #### constructor ()
``` ```
/** /**
@ -22,12 +22,43 @@ constructor (props) {
} }
``` ```
### static getDerivedStateFromProps () #### static getDerivedStateFromProps ()
```
/**
* Props have changed, return the updated state
*
* @param {object} nextProps - Props for the next render
* @param {object} prevState - State from previous render
* @return {object | null} - The change to the state
*/
static getDerivedStateFromProps (nextProps, prevState) {
// Nothing to update
return null;
// Set new state
return {
foo: 'foobar'
};
}
```
#### componentDidMount ()
## Updating ## Updating
### shouldComponentUpdate () #### shouldComponentUpdate ()
#### render ()
#### getSnapshotBeforeUpdate ()
#### componentDidUpdate ()
## Unmounting ## Unmounting
### componentWillUnmount () #### componentWillUnmount ()
---
## Deprecated
### UNSAFE_componentWillMount ()
### UNSAFE_componentWillReceiveProps ()
### UNSAFE_componentWillUpdate ()