FrontendBeginner
State
PronunciationSTAYT
Definition
Data that can change while the app runs and that the screen depends on, such as what the user typed or whether a menu is open.
Where you hear it
React and Vue lessons, and bug reports ("the state is out of sync").
Examples
The cart count is stored in the component state.
The state changed, so React re-rendered the page.
Clicking Add updates the state, and the cart count changes on screen.
Common mistake
Keeping the same data in two places. When one copy changes and the other does not, you get bugs.
Don't confuse with
State represents data that changes within a component over time, whereas props are read-only data passed down from a parent component.
Say it at work
- In a meeting or chat
We need to lift this state up to the parent component so the sibling can access it.
- In an email or ticket
Please ensure the local state is cleared after the form is successfully submitted.