Description

A component shows either a secret message or a hide button. Clicking the button should toggle visibility. It never toggles — the message stays hidden forever.

Anomaly

The button says "Show Secret" and clicking it does nothing. The secret message never appears.

Constraint
Fix only the useState initial value and the toggle logic
Do not restructure the JSX
Hint
Consult the SenseiOnly for those truly stuck · Flip to reveal

What is the onClick handler actually setting visible to?

Loading editor…
Correct Solution
Loading...

Why this fixes it

The click handler called setVisible(false) unconditionally, meaning every click set visible to false regardless of its current value - so the message could never appear. Replacing that with setVisible((v) => !v) passes a functional updater that receives the current state value and inverts it. Because the updater always receives the latest committed state, visible flips correctly between true and false on each click.

Expected OutputGoal State
Your OutputLive