What is the difference between state and props?
Answer
State and props are both JavaScript objects that hold information influencing the rendered output, but they serve different purposes. Props: passed FROM parent TO child; read-only inside the receiving component; the component cannot modify its own props; changes come from the parent re-rendering with new props. State: managed WITHIN the component; can be changed by the component itself via the state setter; triggers a re-render when changed; persists across renders (unlike local variables). Analogy: think of a React component as a function — props are the function's parameters (input from outside), state is the function's local variables (internal data). Decision guide: if the data is passed in from a parent, use props; if the data is owned by this component and can change over time, use state. Never modify props — this is a React rule. State changes are what drive UI updates. Start with props and only introduce state when you need to track something that changes and is not derivable from props.