7.06 Class Component Lifecycle Overview
Lifecycle
only available in class-based components.
And functional components when using React hooks have an equivalent.
Component Lyfecycle
1. Component Creation
Lifecycle Creation Learning Card PDF
Lificycle hooks
& Lifecycle goes
caution
Not to be confused with React Hooks
!
constructor(props) executes
(default ES6 feature)
DO: Set up State
DON'T: Cause Side-EffectsgetDerivedStateFromProps(props, state)
(default lifecycle hook > React 16.3)
static method
DO: Sync State
DON'T: Cause Side-Effectsrender()
Returns JSX.
DO: Prepare & Structure your JSX code
DON'T: No timeouts and Side-EffectsRender Child Components
componentDidMount()
(very important Lifecycle hook)
class-based comps
DO: Cause Side-Effects
DON'T: Update State (triggers re-render)