What is dependency array in useEffect?

Updated May 6, 2026

Short answer

It controls when useEffect runs based on dependencies.

Deep explanation

React compares dependencies using shallow comparison to decide whether to re-run effects.

Real-world example

Re-fetching data when filter changes.

Common mistakes

  • Missing dependencies causing stale values.

Follow-up questions

  • What is shallow comparison?
  • Can you pass empty array?

More React Hooks interview questions

View all →