News for hackers. Stuff that matters.
Re:Thinking in React Hooks by emilecantin on Thursday December 12, 2019 @05:10PM (#21777094)
In this case, onClickOutside was probably a function that you defined inline in your parent component, which would actually be a new thing on each render.

(Something like <Blabla onClickOutsite={() => doSomething()} />)

Since a function is an object, and objects get compared by reference, a new function that does the same thing is not equal to the old function. Thus, this is a change.

Negating it turns that into a boolean, which gets compared by value. false is the same as false, so no change. Any type coercion (e.g turning it into a string) would've worked.

In this case, there's nothing specific to React or hooks, just plain old JS comparison.

There are no comments on this comment yet.