Beginner
Fix the counter that never changes
This counter uses a normal variable, so clicking does nothing on screen. Make it work: the button (it has id="add") must show Clicks: 0 at the start and go up by one on every click.
Use useState from React to give the component memory.
What Check tests
- The button starts at
Clicks: 0 - One click shows
Clicks: 1 - Two more clicks show
Clicks: 3 - The component uses
useState
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
Runs in your browser. Your code is saved here.
Your page
Press Run to see the page.
Console
Nothing logged yet.