AceDevHub
Beginner React Interview QuestionsBeginnerConcept

React · Question 10

What is state in React?

Direct answer

State is component-specific memory that React preserves between renders and uses to produce updated UI.

Use state when a component needs to remember information that can change over time, such as an input value, selected tab, or whether a modal is open.

  • Persistent across renders: local variables reset when the function runs again, state does not.
  • Private to a component instance: rendering the same component twice creates independent state for each position.
  • Updated through React: use a setter instead of mutating the state value directly.