`useEffect` functions that allow custom equality function
andywhite37 opened this issue · 2 comments
andywhite37 commented
The default react useEffect
hook seems to use ===
reference equality to see whether the data has changed. This is fine for primitive values and some scenarios with objects, but sometimes you want a custom equality check.
There's this js lib that adds a useEffect
that uses a deep compare - and I think we can steal some of the implementation approach, but I'd rather just have a hook like:
let useEffectWithEq = (valuesWithEq: list(('a, ('a, 'a) => bool)))
We could do the EQ
as a first-class module too if we wanted to.
A list (or array) of values, each paired with it's own Eq function.
mlms13 commented
A'ight. I'm on it. Let's make the world a better place.