reazen/relude-reason-react

`useEffect` functions that allow custom equality function

andywhite37 opened this issue · 2 comments

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.

A'ight. I'm on it. Let's make the world a better place.

Psh, it's basically done, and I think it might even work correctly? I'm going to tackle #12 before making a 0.8 release, and I want to test this out just a bit more before pushing it out to the world, but it's currently in master.