If you use this optimization, make sure the array includes all values from the component scope (such as props and state) that change over time and that are used by the effect. Otherwise, your code will reference stale values from previous renders. Learn more about how to deal with functions and what to do when the array changes too often.
We recommend using the exhaustive-deps rule as part of our eslint-plugin-react-hooks package. It warns when dependencies are specified incorrectly and suggests a fix.
Shouldn't
loaded
be part of the dependency array?https://github.com/krvajal/use-intercom-hook/blob/999f19bb6fcf0394159cc0ccff693c8dd66aa6f0/src/index.js#L45
https://reactjs.org/docs/hooks-effect.html#tip-optimizing-performance-by-skipping-effects
This is how I noticed it