Too Long; Didn't Read
Optimizing `useEffect` in React gives you a significant boost in performance and sometimes gets your code rid of nasty bugs. Here I'll discuss a few of the optimization patterns which are very easy to adhere to yet very effective. Use primitives in the dependency array instead of objects in the useEffect` dependency array. Sometimes it makes more sense to destructure the JavaScript object and only pass the specific value to the dependency. Avoid needless dependencies like using a closure to get the correct value of a new state.