5 hands-on exercises and 5 find-the-bug challenges for the Writing Custom Hooks lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Move the counter state into a reusable hook.
Return the value and setter as a pair.
Let the hook accept a starting value.
Two independent counters from the same hook.
Let the hook run an effect on mount.
The hook holds the state but hands nothing back.
The hook hardcodes its starting value.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspaceThe hook always returns the same setter value.
Both counters read the same value; each call should be independent.
The hook never runs the effect that sets the stage.