Knowledge Maxxing
← Back to topic library
Dev MaxxingBeginnerReact75 sec

State

State is data a React component manages internally that can change over time, causing the component to re-render whenever it's updated.

Prerequisite: Props

What matters

Unlike props, state belongs to the component itself, letting it respond to things like user input or a timer without needing that data passed in from outside.

Example

A counter component might keep a 'count' value in state, incrementing it and re-rendering to show the new number each time a button is clicked.

Common misconception

Changing a state variable directly, rather than through the component's designated update function, will not reliably trigger a re-render in React.

Recall question

What triggers a React component to re-render when its state changes?

Keywords and related concepts

statere-renderReactprops

Related topics

Props
Dev MaxxingBeginner
React hook
Dev MaxxingBeginner
Effect
Dev MaxxingBeginner