Universal search across Courses, Lessons, Skills, Projects, Challenges, Competitions, Jobs, Internships, and Users
•
1
2
3
4
5
6
7
8
9
10
Components & State•Lesson 2
Component State with useState
Regular local variables reset every time a component renders. The useState hook declares a state variable that React preserves in memory across renders. When you call the setter function (setCount), React schedules a re-render to update the display.
> **Key Takeaway:** useState preserves values between re-renders and instructs React to update the screen when state changes.
Python 3.11
•
Interactive Challenge
+50 XP
Challenge Objective
useState preserves values between re-renders and instructs React to update the screen when state changes.
solution.py
UTF-84 SpacesAuto-saved
cpython3.11:~/workspace
CPython 3.11.8 (WASM)
$python3 -u solution.py
Click "Compile & Run" (or press Ctrl + Enter) to compile AST, verify bytecode, and execute the solution.