4 ms·
I agree it's not intuitive at first. As someone pointed out on Twitter (can't find link at the moment): A good mental model is that the second argument to useE
by bcyn 7y ago
I agree it's not intuitive at first. As someone pointed out on Twitter (can't find link at the moment):
A good mental model is that the second argument to useEffect defines which pieces of state that effect syncs with.
useEffect(() => {}, undefined) // Sync with all state
useEffect(() => {}, []) // Sync with no state
useEffect(() => {}, [a, b]) // Sync with `a` & `b`
- acemarke 7y agoOriginal source was Ryan Florence: https://twitter.com/ryanflorence/status/1125041041063665666 https://twitter.com/ryanflorence/status/1125041041063665666