|
|
|
|
|
by bcyn
2478 days 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` |
|
https://twitter.com/ryanflorence/status/1125041041063665666