useEffect
hook. There's three parts to each useEffect
hook: setup
, cleanup
, and dependencies
where cleanup
and dependencies
are optional.In fact this code will break your browser.
In fact this code will probably break your browser.⚠
useEffect
function is the array of dependencies. Hook behavior changes depending what's in it:null
or undefined
: the hook will run for every render[]
(empty array): the hook will run once, after the first render[value1, value2]
: the hook will only run when one of the values changes