State Basics with useState
Harry
· 22 Sep 2026
· 1 views
Log in to track your progress and mark lessons complete.
Sponsored
The useState Hook
const [count, setCount] = useState(0);
setCount(c => c + 1);Updating Objects and Arrays
Never mutate - spread into new values so React detects the change.
setUser(p => ({ ...p, email: next }));
setItems(p => [...p, item]);State vs Props
State is local and mutable via its setter; props come from the parent and are read-only.
Key Points
- State updates are async and may batch.
- Use functional updates when state depends on previous state.
- Lift shared state to the common parent.