r/reactjs • • Oct 31 '18

Why the hate for React Hooks?

I've been seeing a lot of mixed feelings about React Hooks since it was announced and can't quite figure out why. Sure it's a deviation from the norm, but completely optional and certainly lowers the barrier to entry for new developers.

Can someone explain why all the negative feelings are rising about it?

19 Upvotes

74 comments sorted by

View all comments

Show parent comment

-1

u/leixiaotie Oct 31 '18

Because they use array as 2nd parameter of useEffect. And by default array to array comparison doesn't work in javascript, so they must do some custom equality comparison inside and it "can" be deep equality comparison at least for array type.

And originally, I think they are intended to use that 2nd parameter to present passed params from outside, like this:

let useCustomHook(param1, param2){
  useEffect(() => ...,
    [param1, param2]);
}

Which that passed param is very likely to be array. I think it need to be documented.