Props vs State in React: When to Use Which
Props and state are often confused. Here is a clear way to decide which one to use in any situation.
Props vs State in React: When to Use Which
Props and state are the two kinds of data in React, and beginners constantly mix them up. Here is a clear way to decide which to use.
The Simple Rule
If the data comes from outside the component, it is props. If the data is owned and changed by the component itself, it is state.
Props: External Inputs
Props are passed in by a parent. The component cannot change them. Use props when a value is provided from above and the component just reads and displays it.
State: Internal Memory
State is created inside the component with useState. The component can change it. Use state when the component needs to track something that changes over time, like a counter or a form input.
When a Value Is Both
Sometimes a value starts as a prop but the component needs to change it. The right move is usually to keep the value in the parent's state and pass it down as a prop, with a callback to change it. This is called a controlled component.
Do Not Duplicate
A common bug is copying a prop into state and then letting the two drift apart. Keep one source of truth. If the parent owns the value, let it own the changes too.
Derived Values
If a value can be computed from props or existing state, do not store it in state. Compute it during render. Storing derived values creates sync bugs.
The Takeaway
Props are read-only inputs from the parent. State is internal, changeable memory. When unsure, ask: who owns this data and who changes it? That answer tells you props or state.
Ask who owns and changes the data. If the value comes from outside the component and is read-only, it is props. If the component owns the data and needs to change it over time, it is state.
Copying a prop into state is usually a mistake because the two can drift apart. If the value needs to change, the parent should keep it in state and pass it down as a prop with a callback to update it. This is the controlled component pattern.
No. If a value can be computed from props or existing state, compute it during render instead of storing it. Storing derived values creates synchronization bugs when the source changes.
State is owned by the component that declares it with useState. If multiple components need the same state, lift it to their common parent and pass it down as props, possibly with callbacks to update it.
Because the two copies can go out of sync, producing bugs that are hard to trace. Keeping a single source of truth for each piece of data is a core React principle that prevents these issues.
Ready to master React completely?
Want to upskill yourself, crack your next interview, and get your dream job? Join our comprehensive course to dive deeper with high-quality video tutorials, solve interview questions, and a premium community.
Master React
Want to upskill yourself, crack your next interview, and get your dream job? Join our comprehensive course.

