doesn't work with sets
See original GitHub issueuse-deep-compare-effect
version: v1.3.0node
version: 12yarn
version: 1.21.1
Relevant code or config
const set = new Set(props.someList)
useDeepCompareEffect(() => {
// some effects
}, [set])
What you did:
I am trying to deeply compare a Set
of values but it turns out that the underlying
dequal
library doesnt handle Set
comparison correctly.
example
var dequal = require("dequal")
let a = new Set([1,2,3,4])
let b = new Set([1,2,3,4])
console.log(dequal(a,b))
Check it running here https://runkit.com/embed/yiu9lr2kont0
What happened:
Each set is computed as different even though they should be computed as equal.
Problem description:
dequal
seems to be not best library to do deep equals
Suggested solution:
We could potentially choose one of three
- do a PR to
dequal
fixing this issue - make the comparison mechanism a parameter in
useDeepCompareEffect
- change to a more standard mechanism such as lodash’s
isEqual
that does compute this Set equality appropriately
hope this also helps documenting the current limitation of this otherwise awesome library.
Thanks a lot for everything and sorry to bug you (Pawn Intended)
Fran
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Python sets: "in" set command not working - Stack Overflow
There are two issues here... First, it would seem like you are not testing membership at the correct depth of a nested data...
Read more >assertEquals doesn't work for sets · Issue #2296 · cbeust/testng
assertEquals yields true if called with two sets that contain the same elements, even if they are defined as Collection . Actual behavior....
Read more >Problem in understanding set theory - Math Stack Exchange
In set theory we not only regard the elements of a set as mathematical objects, but the sets themselves as mathematical objects, and...
Read more >Sets in Python - Real Python
In this tutorial you'll learn how to work effectively with Python's set data type. You'll see how to ... Don't forget that set...
Read more >Python Sets Tutorial: Set Operations & Sets vs Lists - DataCamp
The problem with nested sets is that you cannot normally have nested Python sets, as sets cannot contain mutable values, including sets. Frozensets....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
🎉 This issue has been resolved in version 1.4.0 🎉
The release is available on:
npm package (@latest dist-tag)
Your semantic-release bot 📦🚀
Thanks @lukeed!