4 Tips to avoid pitfalls when using useEffect in React

useEffect is the most widely used hook in React. It is handy and looks easy to use, but you must experience infinite loops or some unexpected result when using useEffect. In this article, I try to give you some tips to avoid those typical pitfalls when using it.

Tip #1 understand the mind concept of useEffect

function useEffect(effect: EffectCallback, deps?: DependencyList): void
type EffectCallback = () => void | (()…