← React Fundamentals

Lesson 2 of 3 · 11 min

State & interactivity

useState gives a component memory: const [count, setCount] = useState(0).

Calling the setter re-renders the component with the new value — never mutate state directly.

Practice

Build a counter with a button that increases the number each click.

Quiz

+50 pts
1. Component memory comes from…
2. To update state you…

Optional resources

Your lesson toolkit

No purchase or partner signup is required to complete this course or earn quiz points.

These are official product links, not active affiliate links. Learnly does not currently earn a commission from them.

React documentation

Follow the official component and state tutorials.

Free documentation.

Explore tool

CodeSandbox

Prototype React components in the browser.

Free tier available; paid plans optional.

Explore tool