diff --git a/README.md b/README.md index 6429f43..61de252 100644 --- a/README.md +++ b/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 () \ No newline at end of file +#### componentWillUnmount () + +--- +## Deprecated + +### UNSAFE_componentWillMount () +### UNSAFE_componentWillReceiveProps () +### UNSAFE_componentWillUpdate () \ No newline at end of file