The problem with useEffect

J-oin The Discord! → VSCode Theme | Font → Material Theme Darker | Menlo, Monaco “monospace“ Let’s talk about useEffect in React for a bit. There is a real problem with useEffect that we, as React developers, need to address. useEffect doesn’t make it easy for us to follow its rules correctly, and that usually leads to developers taking shortcuts and shipping bugs in production. The rule is this: anything that is used in the useEffect is considered a dependency and has to go in the dependency array. It’s the rule. If you have to wrap the dependency in a useMemo or useCallback, then you have to do it. Don’t ignore it like many developers do and don’t disable eslint! It’s going to come back and get you later!
Back to Top