0
State Management · Introduction to State Management
New technique
What is state?
Welcome to the Great Ledger, smith. Every forge keeps a record of what's true right now: that record is state.
State is any data that changes over time and affects what the user sees: is the menu open, what's typed in the search box, who is logged in, which orders came back from the server.
State management is how you store, update and share that data so the app stays predictable.
- Fixed values (your app's name, a colour constant) are not state.
- If it changes while the app runs and the UI depends on it, it's state.
- In React, a component keeps state with
const [value, setValue] = useState(initial). Calling the setter re-renders the UI.