Answer
State management refers to how an app organizes and shares data that changes over time, such as the current logged in user, items in a shopping cart, or a form's values. Small apps often manage this using useState and Context directly, while larger apps sometimes reach for a dedicated state management library to keep things organized.
function App() {
const [cartItems, setCartItems] = useState([]);
function addToCart(item) {
setCartItems([...cartItems, item]);
}
return <ProductList onAddToCart={addToCart} />;
}Real-world example A small online store manages its shopping cart entirely with useState at the top of the app, passing the cart data and update function down to whichever components need them.