- For class components that extend React.Component
- When should you use class components vs functional components?
- you can have state
- you have lifecycle Methods
- Container components tend to be class
- more like or going to contain state
- Start off making your component functional -> refactor to class if needed
- Presentational components tend to be functional (dumb components)
- http://projects.wojtekmaj.pl/react-lifecycle-methods-diagram/
- https://reactjs.org/docs/react-component.html
- Walk through
componentDidMount()
- fetch
- add extra event listeners
- set up timers
- things that require the DOM
render()
- has a return value
- don't update state here
componentDidUpdate()
- fetch maybe?
componentWillUnmount()
- called right before element is removed from DOM
- clean up things from componentDidMount
- ComponentDidMount
- ComponentDidUpdate
- Event handlers
shouldComponentUpdate()
getDerivedStateFromProps()
getSnapshotBeforeUpdate()
componentWillMount()
componentWillReceiveProps()
componentWillUpdate()