Props and State are two ways of managing data in React, but with different "rules of the game".
Simple analogy: Imagine you are a chef (component).
Another analogy: Think of props as the weather — it comes from outside (parent), and you cannot control it. State is like your thermostat — you set it yourself based on your needs, and when you change it, the house adjusts (re-render).
Details:
Props (properties):
1<UserCard name="Alice" age={25} /> // props: name and age2// Inside UserCard these props cannot be changed!
State:
1const [count, setCount] = useState(0); // state2setCount(count + 1); // Changing state → component re-renders
How data flows in React:
1function Parent() {2 const [userName, setUserName] = useState("Alice");3 return (4 <div>5 <h1>Welcome, {userName}</h1> {/* Reading state */}6 <Child name={userName} /> {/* Passing state as props */}7 <input onChange={e => setUserName(e.target.value)} />8 </div>9 );10}1112function Child({ name }) {13 return <p>Child sees: {name}</p>; {/* Reading props */}14}
Why it matters:
Common mistakes:
props.name = "Bob" — this will throw an error.count++ instead of setCount(count + 1) — this won't trigger a re-render.When to lift state up: If two sibling components need the same data, lift the state to their closest common parent and pass it down via props.
Key difference: Props come from above and CANNOT be changed. State lives inside and CAN be changed (through special functions). Changing state triggers re-rendering. Props changes also trigger re-rendering of the receiving component.