Props allow React components to receive information from their parent components. After learning how to pass props, the next step is understanding how to read and use those props inside a component.
Reading props means accessing the values that a parent component has provided so the child component can use them to display content, control styles, perform calculations, make decisions, or trigger other logic.
For example, a parent component can pass a user’s name to a child component:
function App() {
return <User name="Karimulla" />;
}
The User component can then read the name prop:
function User(props) {
return <h2>Hello, {props.name}</h2>;
}
The browser displays:
Hello, Karimulla
The basic flow is:
Parent Component
↓
Pass Props
↓
Child Component
↓
Read Props
↓
Render UI
What Does Reading Props Mean?
When a component receives props, React makes those values available through the component’s props object.
For example:
function User(props) {
return <h2>{props.name}</h2>;
}
If the parent renders:
<User name="Karimulla" />
the child receives a props object conceptually similar to:
{
name: "Karimulla"
}
Therefore:
props.name
reads the value of the name prop.
You can think of the process like this:
<User name="Karimulla" />
↓
props = {
name: "Karimulla"
}
↓
props.name
↓
"Karimulla"
Reading a Single Prop
Suppose a parent passes a name prop:
function App() {
return <Welcome name="Karimulla" />;
}
The child can read the value using props.name:
function Welcome(props) {
return <h2>Welcome, {props.name}</h2>;
}
The output is:
Welcome, Karimulla
The important part is:
props.name
The props object contains the properties passed by the parent.
Reading Multiple Props
A component can read multiple props from the same props object.
For example:
function App() {
return (
<Profile
name="Karimulla"
role="Frontend Developer"
location="Hyderabad"
/>
);
}
The child can read all three values:
function Profile(props) {
return (
<div>
<h2>{props.name}</h2>
<p>{props.role}</p>
<p>{props.location}</p>
</div>
);
}
Each prop is accessed using its property name:
props.name
props.role
props.location
This allows one component to display multiple pieces of information supplied by its parent.
Reading Props with Destructuring
Instead of accessing every value through the props object, you can destructure props directly in the function parameter.
For example:
function Profile({ name, role, location }) {
return (
<div>
<h2>{name}</h2>
<p>{role}</p>
<p>{location}</p>
</div>
);
}
This is equivalent to:
function Profile(props) {
return (
<div>
<h2>{props.name}</h2>
<p>{props.role}</p>
<p>{props.location}</p>
</div>
);
}
Both approaches work.
Destructuring often makes a component easier to read because the props used by the component are visible directly in its function parameters.
Props Object vs Destructured Props
Consider this component:
function Course(props) {
return (
<div>
<h2>{props.title}</h2>
<p>{props.level}</p>
<p>{props.duration}</p>
</div>
);
}
The same component can be written using destructuring:
function Course({ title, level, duration }) {
return (
<div>
<h2>{title}</h2>
<p>{level}</p>
<p>{duration}</p>
</div>
);
}
The rendered result is the same.
The difference is how the component accesses its props.
| Approach | Example |
|---|---|
| Props object | props.title |
| Destructuring | title |
| Props object | props.level |
| Destructuring | level |
| Props object | props.duration |
| Destructuring | duration |
Reading String Props
String props can be read directly.
The parent:
function App() {
return <Message text="Start learning React today!" />;
}
The child:
function Message({ text }) {
return <p>{text}</p>;
}
The output is:
Start learning React today!
You can also combine a prop with other text:
function Message({ name }) {
return <p>Hello, {name}. Welcome to Web4Learners!</p>;
}
Reading Number Props
Number props can be read and used in calculations.
The parent:
function App() {
return <Progress percentage={75} />;
}
The child:
function Progress({ percentage }) {
return <p>Progress: {percentage}%</p>;
}
Because percentage is a number, you can also perform calculations:
function Progress({ percentage }) {
const remaining = 100 - percentage;
return (
<div>
<p>Completed: {percentage}%</p>
<p>Remaining: {remaining}%</p>
</div>
);
}
If the parent passes:
<Progress percentage={75} />
the component can display:
Completed: 75%
Remaining: 25%
Reading Boolean Props
Boolean props are useful when a component needs to know whether something is available, active, disabled, completed, or enabled.
For example:
function App() {
return <Course available={true} />;
}
The child can read the boolean value:
function Course({ available }) {
return (
<p>
{available ? "Course Available" : "Course Unavailable"}
</p>
);
}
Boolean props are particularly useful for conditional rendering and component behavior.
For example:
function Button({ disabled }) {
return (
<button disabled={disabled}>
Submit
</button>
);
}
The parent controls the value:
<Button disabled={true} />
Reading Props Inside JavaScript Logic
Props aren’t limited to displaying information.
You can use them inside normal JavaScript logic.
function Course({ progress }) {
let message;
if (progress === 100) {
message = "Course completed!";
} else {
message = "Keep learning!";
}
return <p>{message}</p>;
}
Here, the progress prop determines which message is displayed.
Props can influence:
- Conditional rendering
- Calculations
- Styling
- Event behavior
- Lists
- Function calls
- UI messages
- Component behavior
Reading Props in Conditional Rendering
Props are frequently used with conditional rendering.
For example:
function Course({ completed }) {
return (
<div>
<h2>React Course</h2>
{completed && <p>Course Completed!</p>}
</div>
);
}
The parent can pass:
<Course completed={true} />
The completion message appears.
If the parent passes:
<Course completed={false} />
the message is not rendered.
You can also use a ternary expression:
function Course({ completed }) {
return (
<p>
{completed ? "Completed" : "In Progress"}
</p>
);
}
Reading Props for Dynamic Styling
Props can control the styling of a reusable component.
For example:
function Button({ variant }) {
return (
<button className={`button ${variant}`}>
Click Me
</button>
);
}
The parent can provide the variant:
<Button variant="primary" />
Or:
<Button variant="secondary" />
The component stays the same while its appearance can change based on the prop.
This is a common pattern for reusable buttons, badges, cards, alerts, navigation items, and other UI components.
Reading Object Props
When an object is passed as a prop, the component can access its properties.
The parent:
function App() {
const user = {
name: "Karimulla",
role: "Frontend Developer",
experience: 1
};
return <Profile user={user} />;
}
The child can read the object’s properties:
function Profile({ user }) {
return (
<div>
<h2>{user.name}</h2>
<p>{user.role}</p>
<p>{user.experience} year experience</p>
</div>
);
}
You can also destructure the object:
function Profile({ user }) {
const { name, role, experience } = user;
return (
<div>
<h2>{name}</h2>
<p>{role}</p>
<p>{experience} year experience</p>
</div>
);
}
Reading Array Props
Arrays can be received through props and processed inside the component.
The parent:
function App() {
const topics = [
"JSX",
"Components",
"Props",
"State"
];
return <TopicList topics={topics} />;
}
The child:
function TopicList({ topics }) {
return (
<ul>
{topics.map((topic) => (
<li key={topic}>{topic}</li>
))}
</ul>
);
}
The component reads the topics array and creates an <li> element for each item.
This pattern is commonly used for:
- Course lists
- Navigation menus
- Product cards
- Blog posts
- Search results
- User lists
- Dashboard data
Reading Function Props
A function can be passed to a component as a prop.
For example, the parent defines a function:
function App() {
function handleMessage() {
alert("Hello from the parent!");
}
return <Button onClick={handleMessage} />;
}
The child receives the function:
function Button({ onClick }) {
return (
<button onClick={onClick}>
Show Message
</button>
);
}
Here, onClick is a prop containing a function.
The child doesn’t need to know how the function is implemented. It can invoke that function when the appropriate event occurs.
This pattern is commonly used for communication from a child component back to its parent.
Reading the children Prop
React provides a special children prop when content is placed between a component’s opening and closing tags.
For example:
function App() {
return (
<Card>
<h2>Learn React</h2>
<p>Start building modern interfaces.</p>
</Card>
);
}
The Card component can read that content through children:
function Card({ children }) {
return (
<div className="card">
{children}
</div>
);
}
The children prop makes it possible to create flexible wrapper and layout components.
Reading Props with Default Values
Sometimes a parent may not provide a particular prop.
You can define a default value during destructuring:
function Welcome({ name = "Guest" }) {
return <h2>Welcome, {name}</h2>;
}
When a name is provided:
<Welcome name="Karimulla" />
the output is:
Welcome, Karimulla
When no name is provided:
<Welcome />
the default value is used:
Welcome, Guest
Default values are useful when a prop is optional.
What Happens When a Prop Is Missing?
Suppose a component expects a name prop:
function User({ name }) {
return <h2>{name}</h2>;
}
But the parent renders:
<User />
The name value will be undefined.
If the prop is optional, you can provide a default:
function User({ name = "Guest" }) {
return <h2>{name}</h2>;
}
Or handle the missing value conditionally:
function User({ name }) {
return (
<h2>
{name ? `Welcome, ${name}` : "Welcome, Guest"}
</h2>
);
}
Props Can Change
A child should not modify its props directly, but the value it receives can change when the parent renders the child with a different value.
For example:
function App() {
const [progress, setProgress] = useState(50);
return <Progress percentage={progress} />;
}
If the parent updates its state:
setProgress(75);
the child can receive the new value:
function Progress({ percentage }) {
return <p>{percentage}% complete</p>;
}
The important distinction is:
Props are read-only from the child’s perspective, but a parent can provide different prop values when it renders again.
Reading Props Does Not Mean Changing Props
Reading and changing props are two different things.
Reading a prop is completely normal:
function Course({ title }) {
return <h2>{title}</h2>;
}
However, a child should not try to modify the received prop:
function Course({ title }) {
title = "JavaScript";
return <h2>{title}</h2>;
}
Instead, the component should treat the prop as an input.
If the value needs to change, the appropriate owner of that data should update it and pass the new value to the child.
Common Mistakes When Reading Props
Forgetting the Props Parameter
Incorrect:
function User() {
return <h2>{props.name}</h2>;
}
Here, props hasn’t been defined.
Correct:
function User(props) {
return <h2>{props.name}</h2>;
}
Or use destructuring:
function User({ name }) {
return <h2>{name}</h2>;
}
Using the Wrong Prop Name
If the parent passes:
<User username="Karimulla" />
the child needs to read username:
function User({ username }) {
return <h2>{username}</h2>;
}
Reading name instead would result in an undefined value because name wasn’t the prop that was provided.
Confusing Strings and Variables
This passes the literal text "name":
<User name="name" />
This passes the value stored in the JavaScript variable name:
<User name={name} />
The curly braces tell JSX to evaluate the JavaScript expression.
Calling a Function Prop During Rendering
Suppose a function is passed as a prop:
<Button onClick={handleClick} />
The child can provide that function to the event handler:
<button onClick={onClick}>
Click
</button>
Avoid:
<button onClick={onClick()}>
Click
</button>
because this calls the function while rendering instead of passing the function to be called by the event.
Assuming Missing Props Have Automatic Values
If a prop isn’t provided, React doesn’t automatically know what value you intended.
You can provide a default:
function User({ name = "Guest" }) {
return <h2>{name}</h2>;
}
Best Practices for Reading Props
- Use descriptive prop names.
- Destructure props when it improves readability.
- Treat props as read-only.
- Provide default values for optional props when appropriate.
- Use the correct data type for each prop.
- Use props for data that should come from the parent.
- Use function props for event communication.
- Use arrays for collections of related data.
- Use objects when several related values belong together.
- Keep component APIs focused.
- Don’t duplicate prop values unnecessarily.
- Handle optional props intentionally.
Reading Props vs Reading State
Props and state can both provide values to a component, but they serve different purposes.
| Props | State |
|---|---|
| Usually comes from a parent | Belongs to the component that owns it |
| Used to receive data | Used to manage changing data |
| Read-only to the receiving component | Updated using state setters |
| Helps make components reusable | Helps make components interactive |
| Parent controls the value | Component can update its own state |
For example:
function Course({ title }) {
const [progress, setProgress] = useState(0);
return (
<div>
<h2>{title}</h2>
<p>{progress}% complete</p>
</div>
);
}
Here:
title
↓
Prop from parent
progress
↓
State managed by component
Understanding this difference is important when building larger React applications.
A Simple Mental Model
When you see:
<Course
title="React"
level="Beginner"
progress={75}
/>
think of it as:
Parent gives the child three values
title → "React"
level → "Beginner"
progress → 75
The child receives them:
function Course({ title, level, progress }) {
// Read the values here
}
And uses them:
<h2>{title}</h2>
<p>{level}</p>
<p>{progress}%</p>
The complete flow is:
Parent
↓
Pass Props
↓
Child Receives Props
↓
Read Props
↓
Use Props in JSX or JavaScript
↓
Rendered UI
Web4Learners Practical Example
Imagine Web4Learners displays tutorial cards.
The parent provides information:
function App() {
return (
<TutorialCard
title="Reading Props in React"
category="React"
difficulty="Beginner"
duration="10 minutes"
/>
);
}
The reusable component reads those props:
function TutorialCard({
title,
category,
difficulty,
duration
}) {
return (
<article className="tutorial-card">
<span>{category}</span>
<h2>{title}</h2>
<p>Difficulty: {difficulty}</p>
<p>Duration: {duration}</p>
</article>
);
}
Another tutorial can use exactly the same component:
<TutorialCard
title="React State"
category="React"
difficulty="Intermediate"
duration="15 minutes"
/>
The component doesn’t need to be rewritten.
Only the prop values change.
This is one of the key ideas behind reusable React components.
Image Placement
Place the image immediately after the section “What Does Reading Props Mean?”
Create a modern 16:9 Web4Learners-style React infographic showing a parent component passing props to a child and the child reading those values. Show App on the left, name="Karimulla" and role="Developer" flowing through a props object in the center, and User on the right reading props.name and props.role. Keep the text minimal and make the data flow visually obvious.
Caption: Reading values passed from a parent component through React props.
Alt text: React child component reading name and role values from props.
Practice Exercise
Create a reusable StudentCard component.
The parent should pass:
namecourselevelprogresscompleted
Start with:
function App() {
return (
<StudentCard
name="Karimulla"
course="React"
level="Beginner"
progress={80}
completed={false}
/>
);
}
Create the StudentCard component and read all five props.
Then:
- Display the student’s name.
- Display the course.
- Display the level.
- Display the progress.
- Show
"Course Completed"only whencompletedistrue. - Create another
StudentCardwith different values.
Reading Props Cheat Sheet
| Task | Example |
|---|---|
| Receive props | function User(props) |
| Read a prop | props.name |
| Destructure props | function User({ name }) |
| Read multiple props | props.name, props.role |
| Read a number | {progress} |
| Read a boolean | {available} |
| Read an object | user.name |
| Read an array | topics.map(...) |
| Read a function | onClick() |
| Read children | {children} |
| Default value | { name = "Guest" } |
| Conditional use | {completed && <p>Done</p>} |
Key Takeaways
- Reading props means accessing values provided by a parent component.
- Props are available through the
propsobject. - A prop can be accessed using
props.propName. - Props can also be destructured directly in the component parameter.
- Props can contain strings, numbers, booleans, objects, arrays, functions, and JSX.
- Props can be used in JSX and regular JavaScript logic.
- Props can control content, styling, behavior, and conditional rendering.
- The
childrenprop provides content placed inside a component’s opening and closing tags. - Missing props have an
undefinedvalue unless a default is provided. - The receiving component should treat props as read-only.
- A parent can provide different prop values when it renders again.
- Reading props correctly is essential for building reusable React components.