React
React useState HookReact useState Hook
The useState Hook creates state variables in functional components.
Read Time
5 min readDifficulty
BeginnerLast Updated
Jun 15, 2026Version
v1.0.0Introduction
Developers use the `useState` Hook to add memory to a component. It returns two things: the current value of the state, and a function specifically designed to update that value safely.
Example
Example
Key Points
- Import `useState` from the `react` library.
- The Hook returns an array with a variable and a setter function.
- Never modify the state variable directly.
- Always use the setter function (like `setCount`) to update it.