View Code? Open in Web Editor
NEW
This project forked from adamwjo/lifecycle-forms-code-along
HTML 0.84%
JavaScript 5.03%
CSS 94.13%
lifecycle-forms-code-along's Introduction
React Component Lifecycle
- 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)
Lifecycle Methods only for class components
componentDidMount()
- fetch
- add extra event listeners
- set up timers
- things that require the DOM
Setting Initial State using Props
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()
lifecycle-forms-code-along's People
Contributors