Training Grounds
Ref Instead of StateBlack Belt
+50 Ki
Description

A component tracks how many times a user has clicked a secret area. The click count is stored in a ref. The displayed count never updates.

Anomaly

Click the secret area repeatedly — the counter on screen stays at 0. The ref value is updating internally but the UI never reflects it.

Constraint
Replace the ref with useState for the click count
Keep any other refs in the component unchanged
Hint

Refs are mutable containers that do not trigger re-renders when changed. If you need a value to appear in the UI, it must live in state.

Consult the SenseiOnly for those truly stuck · Flip to reveal

Refs are mutable containers that do not trigger re-renders when changed. If you need a value to appear in the UI, it must live in state.

Loading editor…
Correct Solution
Loading...
Expected OutputGoal State
Your OutputLive