diff --git a/README.md b/README.md index 71ddefe..de45993 100644 --- a/README.md +++ b/README.md @@ -45,17 +45,72 @@ static getDerivedStateFromProps (nextProps, prevState) { #### componentDidMount () +```js +/** + * Component mounted, will render soon + */ +componentDidMount () { + // Network calls, state changes, + // anything is fair game here +} +``` + ## Updating #### shouldComponentUpdate () + +```js +/** + * Hook to control re-render + * + * @param {object} nextProps + * @param {object} nextState + * @return {boolean} - Whether to render this cycle + */ +shouldComponentUpdate (nextProps, nextState) { + // Default in React.Component + return true; + + // React.PureComponent implements this method + // with a shallow compare of props and state +} +``` #### render () + +```js +/** + * Render returned components + * + * @return {React Element | string | number | Portal | null | boolean} + */ +render () { + return
; +} +``` #### getSnapshotBeforeUpdate () + +```js +getSnapshotBeforeUpdate (prevProps, prevState) { +} +``` #### componentDidUpdate () +```js +componentDidUpdate (prevProps, prevState, snapshot = undefined) { +} +``` + ## Unmounting #### componentWillUnmount () +```js +componentWillUnMount () { + // Cleanup whatever you need to before the + // component unmounts +} +``` + --- ## Deprecated