Description

A like button shows a count and toggles between liked and unliked. Clicking Like adds 1 to the count. Clicking Unlike should remove 1 - instead the count keeps going up.

Anomaly

Click Like - count goes to 1, button shows Unlike. Click Unlike - count goes to 2 instead of back to 0. Every click increments regardless of direction.

Constraint
Do not change the reducer logic
Hint
Consult the SenseiOnly for those truly stuck · Flip to reveal

The reducer looks correct - so where else could the wrong behavior come from?

Loading editor…
Correct Solution
Loading...

Why this fixes it

`handleClick` always dispatched `{ type: 'LIKE' }` unconditionally - the reducer's `UNLIKE` branch existed and was correct, but it was unreachable because the dispatch call never sent that action type regardless of the current `liked` state. Replacing the hardcoded string with `state.liked ? 'UNLIKE' : 'LIKE'` makes the dispatched action type conditional on the current state, so the correct branch is selected on every click. The reducer itself required no changes - the entire bug lived at the call site, not in the state transition logic.

Expected OutputGoal State
Your OutputLive