What is state in React?

Why Interviewers Ask This

Foundational questions like this help interviewers calibrate the rest of the interview. A confident, accurate answer signals that you have solid React.js basics — a prerequisite for any developer role.

Answer

State is data that a component manages internally and that can change over time. When state changes, React re-renders the component (and its children) to reflect the updated UI. Unlike props (which come from outside), state is owned and managed by the component itself. In function components, state is created with the useState hook: const [count, setCount] = useState(0);. count is the current state value; setCount is the updater function. Call setCount(newValue) to update the state — React queues a re-render. Important rules: (1) Never mutate state directly — always use the setter function. (2) State updates may be batched — React 18 batches all updates by default. (3) State updates are asynchronous — reading state right after calling the setter gives the old value. (4) For state based on the previous value, use the functional update form: setCount(prev => prev + 1). State should be the minimum data needed to represent the UI — derive everything else from state and props.

Pro Tip

Back up your answer with a specific project or situation. Saying 'In my last React.js project, I used this when...' immediately makes your answer more credible and memorable.