React useState WTF moment

Motherfucker! The useState setter can fire multiple times, at least twice. This means that the new value can't be based on the current value. So I can't do value => !value, because on the next run it will reverse the previously set value.

It's the first time I'm facing this shit. What the hell?!

I'm not sure why this is happening. The wrapping caller is called once, but the setter function is called twice. Fuck. The obvious way around this is to pass the value to the setter and not take it from the current useState value.