dependency array
The array of values given to hooks such as useEffect, useMemo and useCallback that tells React when to re-run them.
In more detail
React compares each item with Object.is against the previous render; if any changed, the hook re-runs. An empty array means run only after mount. Leaving out a value the code uses creates a stale closure, so the eslint-plugin-react-hooks rule checks the list for you.
Example
useEffect(() => { ... }, [id]);Related terms
- useEffect — The React hook for running side work, such as adding listeners or changing document.body, after a component renders.
- stale closure — A function that still sees old values because it was created during an earlier render and never replaced.
- Object.is — The JavaScript function that tells whether two values are the same value, comparing objects by identity.
- eslint-plugin-react-hooks — The official ESLint plugin that checks React code for Rules of Hooks violations and incomplete dependency arrays.
Taught in
- useEffect Lifecycle: Mount, Dependencies, And Cleanup Phases — React 19 & Modern Component Architecture
- useImperativeHandle: Controlled Ref Forwarding Boundaries — React 19 & Modern Component Architecture
- Higher-Order Components And Render Props: Tradeoff Analysis — React 19 & Modern Component Architecture
- Creating Event Listener Hooks with Clean Teardown Logic — React 19 & Modern Component Architecture
- React.memo, useMemo, And useCallback: Optimization Costs — React 19 & Modern Component Architecture
- The React Compiler: Automated Memoization Under The Hood — React 19 & Modern Component Architecture
- Accessible Headless Primitives: ARIA, Focus, And Keyboard — React 19 & Modern Component Architecture