useEffect
For data fetching, subscriptions, or manually changing the DOM because they can affect other components and can’t be done during rendering.
useEffect
Hook runs after every render and offers clean up so === to componentDidMount
, componentDidUpdate
, and componentWillUnmount
combined.
Conditional Effect
Pass an empty array([]
) if you only want the effect on mount and unmount
Clean up
Add as return
Last updated