🌐UI State
Also known as State, Component State, Application State
The data a page holds right now that can change, like a count.
Think of it like
Think of it like a scoreboard. When the score changes, the board shows the new number.
Example
Jack's cart icon shows a number. That number is state, and adding a mug changes it from 2 to 3.
Why it matters
Most front-end bugs are state bugs. Knowing where state lives makes them easy to find.
Definition
Example code
jsx
const [count, setCount] = useState(0);
<button onClick={() => setCount(count + 1)}>{count}</button>Common mistake
Key takeaways
- 1Data that changes. Counts, inputs, open or closed.
- 2The screen follows. Change state, not the page.
- 3One home per fact. No copies to drift apart.