Lifecycle Phases

Three Phases

MOUNTING      component is created and inserted into the DOM
   ↓
UPDATING      props or state change → re-render (can happen many times)
   ↓
UNMOUNTING    component is removed from the DOM
PhaseClass componentFunction component
Mountconstructor → render → componentDidMountrender → useEffect(fn, [])
Updaterender → componentDidUpdate(prevProps, prevState)render → useEffect(fn, [deps])
UnmountcomponentWillUnmountcleanup returned from useEffect
Skip re-rendershouldComponentUpdate / PureComponentReact.memo
ErrorscomponentDidCatch / getDerivedStateFromErrorno hook: use a class error boundary