Using objects/arrays in deps for React useEffect can cause it to run the effect on *every* re-render even if contents are the same cuz the references are different
We've got a couple of options...
Depend on the obj properties instead of the entire obj
/thread
We've got a couple of options...

/thread



In general creating object literals is cheap so the perf wins from optimized useEffect should outweigh the duplication



This is suggested by the `react-hooks/exhaustive-deps` ESLint rule (part of `eslint-plugin-react-hooks` which you should totally be using)





(the eslint rule will be very unhappy tho)


I go over these 4 options for optimizing the React useEffect Hook w/ object or array dependencies in greater detail in my latest post
Is this a problem that you've even run into?
Have you solved it w/ other methods?

https://www.benmvp.com/blog/object-array-dependencies-react-useEffect-hook/?utm_source=twitter&utm_medium=social&utm_campaign=init-share
Is this a problem that you've even run into?

Have you solved it w/ other methods?



BTW if you enjoy this sort of content, don't miss out and subscribe to the BenMVP Newsletter 
It's a weekly-ish frontend dev email where I share my posts about JS, TS, React, "divops" & more. Also notifications about my minishops & speaking engagements https://www.benmvp.com/subscribe/?utm_source=twitter&utm_medium=social&utm_campaign=object-array-dependencies-react-useEffect-hook

It's a weekly-ish frontend dev email where I share my posts about JS, TS, React, "divops" & more. Also notifications about my minishops & speaking engagements https://www.benmvp.com/subscribe/?utm_source=twitter&utm_medium=social&utm_campaign=object-array-dependencies-react-useEffect-hook