-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
useDeepCompareEffect throws error when comparing objects created with Object.create(null) #2700
Description
What is the current behavior?
useDeepCompareEffect cannot compare object created with Object.create(null) due to error in fast-deep-equal dependency (See epoberezkin/fast-deep-equal#111). The hook throws TypeError: a.valueOf is not a function
Steps to reproduce it and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have extra dependencies other than react-use. Paste the link to your JSFiddle or CodeSandbox example below:
- Create an object with
Object.create(null) - Add it to the dependency array of
useDeepCompareEffect - Have something update the object with a different object created with
Object.create(null)
https://codesandbox.io/p/devbox/cranky-lake-hshk3h
What is the expected behavior?
Comparison should not throw. Given the fast-deep-equal dependency has not been updated in 6 years, it would be good to update to another one, such as fast-equals
A little about versions:
- OS: Windows
- Browser (vendor and version): Chrome 146
- React: ^18.2.0, ^19.0.0
react-use: 17.5.1, 17.6.0- Did this worked in the previous package version? Unsure