Frontendbeginner

State (React)

Data in a React component that can change over time, triggering the UI to re-render.

Detailed Explanation

State is data that changes over time in your application — a counter value, form input text, whether a menu is open, or a list of items fetched from an API. When state changes, React automatically rerenders the component to reflect the new data.

State is managed with the useState hook: const [count, setCount] = useState(0). The destructured array gives you the current value and a function to update it. For complex state shared across many components, Zustand provides a global store.

Not to be confused with CSS states (like :hover or :focus). React state lives in JavaScript and drives your UI logic, while CSS states are visual conditions based on user interaction.

Code Example

jsx

Ready to Build Something Real?

We give you the skills to build, deploy, and own a full product. Professional stack, AI co-pilot, no coding background required.