Runs onChange synchronously during render whenever any entry in deps
changes, compared shallowly with Object.is against the previous render.
This is React's "adjusting state while rendering" pattern: it replaces a
useEffect that only mirrors props into state, avoiding the extra commit and
the react-hooks/set-state-in-effect lint rule. onChange typically calls
one or more state setters and reads the new values from the enclosing scope.
It does not fire on the initial render.
Parameters
deps: readonlyunknown[]
Values to watch; pass them as a fresh array each render, like
a useEffect dependency list.
Runs
onChangesynchronously during render whenever any entry indepschanges, compared shallowly withObject.isagainst the previous render.This is React's "adjusting state while rendering" pattern: it replaces a
useEffectthat only mirrors props into state, avoiding the extra commit and thereact-hooks/set-state-in-effectlint rule.onChangetypically calls one or more state setters and reads the new values from the enclosing scope. It does not fire on the initial render.