In React, data moves through components via Props and State. Confusing these two is the #1 cause of bugs in frontend apps.
πΉ 1. What are Props? (The "Input")
Props is short for "properties." They are passed from parent to child (like arguments to a function). Props are read-only; a component cannot change its own props.
Example:
// Parent
<User name="Alice" />
// Child
function User(props) {
return <h1>Hello, {props.name}</h1>;
}
πΉ 2. What is State? (The "Memory")
State is internal to a component. It stores data that changes over time (like text in an input or a counter). When state changes, the component re-renders.
Example:
const [count, setCount] = useState(0);
return <button onClick={() => setCount(count + 1)}>{count}</button>;
πΉ 3. Key Differences
β’ Props: External, passed down, immutable (can't be changed).
β’ State: Internal, managed within, mutable (via updater function).
π Think of Props as the "Settings" and State as the "Current Status" of your component.
π― What you should do
βοΈ Understand that data flows down (Props)
βοΈ Use State for data that changes
βοΈ Avoid trying to modify props directly