reason-react
reason-react copied to clipboard
Make explicit array comparison error in useEffectN N>1
I'm working on a project using reason-react and I encountered a mistake which I found hard to solve, and I wanted to contribute to the docs in case anyone else experiences the same issue.
The gist is that my reading of the docs led me to believe that the use of arrays in useEffect
are fine in general, rather than just specifically for useEffect1
.
So, I tried to be clever by gathering like types into arrays, like so:
x : int
y : int
z : string
useEffect2(effect, [|x,y|],z);
But this doesn't work, as the transpiled javascript code will always result in a comparison [x,y]==[x,y]
which is false
always because the arrays are being compared by reference.
I'm not sure if this is the right place to plop these docs in, but please let me know and I am happy to move it around!