π¦ State vs. Props in React .
π¦ State vs. Props in React β A Complete Guide for Beginners | Hasenode

When building modern React applications, two core concepts you will use every day are State and Props. These two terms may sound similar, but they serve very different purposes. Understanding the difference between them is essential for writing clean, reusable, and dynamic React components.
In this Hasenode blog, weβll break down what State is, what Props are, and how they differ, with simple examples to make everything clear.
πΉ What Are Props?
Props (short for properties) are used to pass data from one component to another β typically from a parent component to a child component.
Key Features of Props
Read-only (cannot be modified by the child component)
Used for data flow from parent to child
Make components reusable
Behave like function parameters
β Example of Props
function Welcome(props) {
return <h2>Hello, {props.name}!</h2>;
}
function App() {
return <Welcome name="Sagar" />;
}
Here:
Appβ Parent componentWelcomeβ Child componentname="Sagar"is passed as a prop
πΉ What Is State?
State is used to manage data that changes over time within a component. It is mutable, meaning a component can update its own state.
Key Features of State
Mutable (can change over time)
Used to handle dynamic data
Updates cause the component to re-render
Managed inside the component itself
β Example of State
import { useState } from "react";
function Counter() {
const [count, setCount] = useState(0);
return (
<div>
<p>Count: {count}</p>
<button onClick={() => setCount(count + 1)}>Increase</button>
</div>
);
}
Here:
countis part of the componentβs statesetCount()updates the stateUI updates automatically when the state changes
π State vs. Props β Quick Comparison Table
| Feature | State | Props |
| Definition | Internal data of a component | Data passed from parent to child |
| Mutability | Mutable (can change) | Immutable (read-only) |
| Owned by | The component itself | Parent component |
| Used for | Dynamic data, UI updates | Passing data, configuration |
| Who can update it? | The component | Parent component only |
| Triggers re-render? | Yes | Yes (when parent re-renders) |
π― When to Use What?
β Use State when:
You need to store dynamic or interactive data
A component needs to update its UI
Examples: Counter, form inputs, toggles, modals, cart items
β Use Props when:
You want to pass data into a child component
You need to make components reusable
Examples: Passing name, image, colors, lists, action handlers
π§ Simple Rule to Remember
Props are for passing data.
State is for managing data.
Props = external
State = internal
π Final Thoughts
Mastering State and Props is the foundation of becoming great at React.
Props help you share data across components.
State helps you change the UI dynamically.
When you understand how they work together, building interactive interfaces becomes effortless.



