2 ms·
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. (Som
by emilecantin 7y ago
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.