UPDATE - I think that React does some smart memoization for the dependencies, so my analysis is incorrect. The main thing that would cause a useEffect is performing a setState (the same as using one of the set* useState functions) inside of a useEffect, where the state value is part of the dependency array.
UPDATE - I think that React does some smart memoization for the dependencies, so my analysis is incorrect. The main thing that would cause a
useEffect
is performing asetState
(the same as using one of theset*
useState functions) inside of auseEffect
, where the state value is part of the dependency array.This is a good article that outlines some of the pitfalls and how to solve them: dmitripavlutin.com/react-useeffect...