A component toggles between showing a secret message and a button to reveal it on each click.
The button says "Show Secret" and clicking it does nothing. The secret message never appears.
What is the onClick handler actually setting `visible` to?
What is the onClick handler actually setting `visible` to?
Why this fixes it
The click handler called `setVisible(false)` unconditionally, meaning every click set `visible` to `false` regardless of its current value. Replacing that with `setVisible((v) => !v)` passes a functional updater that receives the current state value and inverts it, flipping correctly between `true` and `false` on each click.