You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
useDeepCompareEffect gives warnings when using it with primitive dependencies. This is frustrating for the common case where dependencies could either undefined or an object that you'd like to be deep-compared.
Describe the solution you'd like
Remove warnings from useDeepCompareEffector provide a way to suppress warnings.
I understand that the warning is there to help users. We should be using useEffect when the values of the dependency array are primitives. However, it's possible for the values of the array to change from primitive to non-primitive (as shown above). In that case, there should be no warning. It is correct to use useDeepCompareEffect if the value of the dependency is either a primitive or a non-primitive.
That warning is only valid if it is always primitive.
If the above case doesn't satisfy you, I'd at least add the option to hide warnings from react-use. Warnings are definitely useful and I appreciate that they're in react-use. However, they clutter the console and, in this case, I simply don't agree with the warning but would still like to continue using react-use.
Activity
xobotyi commentedon Nov 6, 2019
Any example?
geraldarthurdavis commentedon Nov 7, 2019
This code will log a warning whenever
objis set toundefined.geraldarthurdavis commentedon Nov 7, 2019
I understand that the warning is there to help users. We should be using
useEffectwhen the values of the dependency array are primitives. However, it's possible for the values of the array to change from primitive to non-primitive (as shown above). In that case, there should be no warning. It is correct to useuseDeepCompareEffectif the value of the dependency is either a primitive or a non-primitive.That warning is only valid if it is always primitive.
geraldarthurdavis commentedon Feb 12, 2020
If the above case doesn't satisfy you, I'd at least add the option to hide warnings from
react-use. Warnings are definitely useful and I appreciate that they're inreact-use. However, they clutter the console and, in this case, I simply don't agree with the warning but would still like to continue usingreact-use.streamich commentedon Feb 15, 2020
@garrettmaring I agree, I think the warnings for primitives in
useDeepCompareEffect(and shallow compare) should be removed.streamich commentedon Feb 15, 2020
But the other warning about no dependencies should probably stay.
tusharkrbarman commentedon Jan 30, 2023
Is this issue open? Can anyone assign this to me?
shrutipandya3 commentedon Oct 28, 2025
Can I work on this if still open?
fix: Remove warnings from useDeepCompareEffect (fixes streamich#755)
feat: Add production-grade warning suppression for useDeepCompareEffe…
feat: Add warning suppression for useDeepCompareEffect (fixes streami…
fix: Remove warnings from useDeepCompareEffect (fixes streamich#755)
fix: Remove warnings from useDeepCompareEffect (fixes streamich#755)
fix: remove warnings from useDeepCompareEffect
fix: remove warnings from useDeepCompareEffect
fix: remove all-primitive-deps warning from useDeepCompareEffect (closes
fix: remove all-primitive-deps warning from useShallowCompareEffect (c…