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

Taught in

References