← BYTES
React.js·Intermediate·Ref: 4.2.18
If a `useEffect` has an empty dependency array `[]`, when does its effect function run?
Have a question about this video? Mention reference 4.2.18 when you contact us.
a.On every single render, with no exceptions
b.Never -- an empty array disables the effect entirely
c.Only once, right after the component's first render (mount)
d.Only when the component is about to unmount
An empty dependency array tells React "this effect doesn't depend on anything that changes between renders," so it only re-runs if the component were to unmount and remount -- in practice, this means it fires exactly once after the initial render.
Find this on YouTube & Instagram
Every BYTES video is tagged with its reference number and topic — search any of these on YouTube or Instagram to find this one:
#BYTES#BYTES4218#Reactjs