Dependency array
A dependency array is an array passed to a React effect or memoization Hook that specifies values whose changes trigger recomputation or rerunning.
React Hooks in Action: With Suspense and Concurrent Mode
A dependency array is an array passed to useEffect that determines when the effect is run again based on dependency changes.
- How it is used
- Controls when useEffect side effects run as components render, rerender, mount, and unmount.
- How deep it goes
- Explains comparison-driven scheduling, empty and populated arrays, cleanup order, and warnings, without descending into React internals.
- Examples
- Uses window resizing, local-storage user selection, user fetching, and bookables loading to demonstrate dependency choices.
- What you can do after
- Apply dependency arrays to schedule effects, persist state, fetch initial data, and prevent repeated event-listener registration.
Read how React Hooks in Action: With Suspense and Concurrent Mode explains dependency array →
React in Depth
A dependency array is the optional second argument to a React effect or memoization hook that determines when its computation is rerun.
- How it is used
- Controls effect reruns and memoized computations while balancing correct updates against unnecessary work.
- How deep it goes
- Distinguishes omitted, empty, and nonempty arrays; explains referential equality, stable-value exceptions, and maintenance pitfalls.
- Examples
- Uses employee-list filtering, render tracking, and a deletion callback with a stable state setter.
- What you can do after
- Apply it in React hooks to select rerun conditions and diagnose missing or needlessly changing dependencies.
React Quickly, Second Edition
A dependency array is an array passed to a React effect Hook that specifies values whose changes determine when the effect runs again.
- How it is used
- Controls when React effects and their cleanup functions respond to component mounts, renders, unmounts, and selected value changes.
- How deep it goes
- Explains skipped, empty, and value-based arrays with lifecycle examples, but defers detailed implementation internals.
- Examples
- Uses data loading, timers, dialog-close tracking, browser titles, active flags, and unmount cleanup.
- What you can do after
- Apply it via React's useEffect hook to schedule effects and cleanup at selected component lifecycle points.
Read how React Quickly, Second Edition explains dependency array →
Also covered in
What to know first
- componentA software component is a modular part of a software system that encapsulates related functionality and interacts with other parts through defined boundaries.
- renderingRendering is the process of producing a presentational representation or visual output from structured content, data, application state, or a scene.
- side effectA side effect is an observable change or interaction caused by a computation beyond producing its direct result, such as modifying state or interacting with the external environment.
- timerA timer is a mechanism that tracks or schedules time to trigger an event or action after a specified duration or at recurring intervals.
Related concepts
- useEffectconfigures · useEffect is a React Hook that runs effect logic after rendering to synchronize a component with external systems and optionally perform cleanup.
- renderingcontrasts with · Rendering is the process of producing a presentational representation or visual output from structured content, data, application state, or a scene.
- useCallbackuses · useCallback is a React Hook that memoizes a function reference and reuses it across renders until its specified dependencies change.
- useLayoutEffectuses · useLayoutEffect is a React Hook that runs an effect synchronously after DOM mutations and before the browser paints.
- useMemoconfigures · useMemo is a React Hook that caches a calculated value between renders and recomputes it when specified dependencies change.
- arraykind of · An array is an ordered collection of elements organized in one or more dimensions and accessible by position or index.
Questions about dependency array
What is dependency array?
A dependency array is an array passed to a React effect or memoization Hook that specifies values whose changes trigger recomputation or rerunning.
Which Manning books explain dependency array?
React Hooks in Action: With Suspense and Concurrent Mode, React in Depth and React Quickly, Second Edition.
What should I know before learning dependency array?
Manning books that teach dependency array usually introduce component, rendering, side effect and timer first.
What is the difference between dependency array and rendering?
A dependency array is an array passed to a React effect or memoization Hook that specifies values whose changes trigger recomputation or rerunning. Rendering is the process of producing a presentational representation or visual output from structured content, data, application state, or a scene.
What is dependency array a kind of?
Dependency array is a kind of array. An array is an ordered collection of elements organized in one or more dimensions and accessible by position or index.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


