Add more methods, flesh out getDerivedStateFromProps
This commit is contained in:
parent
f077346449
commit
ac10319fd5
39
README.md
39
README.md
@ -6,7 +6,7 @@ Short reference of React.Component lifecycle methods so I don't have to scroll t
|
||||
|
||||
## 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
|
||||
|
||||
### shouldComponentUpdate ()
|
||||
#### shouldComponentUpdate ()
|
||||
#### render ()
|
||||
#### getSnapshotBeforeUpdate ()
|
||||
#### componentDidUpdate ()
|
||||
|
||||
## Unmounting
|
||||
|
||||
### componentWillUnmount ()
|
||||
#### componentWillUnmount ()
|
||||
|
||||
---
|
||||
## Deprecated
|
||||
|
||||
### UNSAFE_componentWillMount ()
|
||||
### UNSAFE_componentWillReceiveProps ()
|
||||
### UNSAFE_componentWillUpdate ()
|
Loading…
Reference in New Issue
Block a user