Mahamudul Hasan Rubel
HomeAboutProjectsSkillsExperienceBlogCoursesPhotosContact
Mahamudul Hasan Rubel

Senior Software Engineer crafting high-performance web applications and SaaS platforms.

Navigation

  • Home
  • About
  • Projects
  • Skills
  • Experience
  • Blog
  • Courses
  • Photos
  • Contact

Get in Touch

Available for senior/lead roles and consulting.

bd.mhrubel@gmail.comHire Me

© 2026 Mahamudul Hasan Rubel. All rights reserved.

Built with using Next.js 16 & Tailwind v4

Back to Blog
Lesson 7 of the React Fundamentals: Build Modern UIs from Scratch course
ReactJune 25, 20263 min read

Passing Data with Props: A Guide to React Component Communication

Learn how to use props to pass data between React components. Master unidirectional data flow to build dynamic, reusable UIs for your movie browser.

reactpropscomponentsfrontendbeginnersjavascript

Previously in this course, we learned about creating static components to build our app's skeleton. While static components are a good start, a real application needs to be dynamic.

Today, we’re moving beyond hard-coded UI by learning how to pass information between components. In React, this is achieved through props.

What are Props?

"Props" is short for properties. Think of them as the arguments you pass to a JavaScript function, but for your React components. They allow a parent component to send data down to a child component, making your UI modular and reusable.

In React, data flow is unidirectional. This means data always travels from the top (parent) down to the bottom (child). By mastering this flow, you ensure your application remains predictable and easy to debug, as we explore in React props vs state: Mastering Unidirectional Data Flow.

Defining and Passing Props

To pass data, you add attributes to your component in JSX, just like you would with standard HTML attributes.

Imagine we are building our movie browser project. Instead of hard-coding a single movie title, we want a MovieTitle component that can display any title we give it.

Here is how you pass data to a child:

JSX
// ParentComponent.jsx
import MovieTitle from CE9178">'./MovieTitle';

function App() {
  return (
    <div>
      {/* We pass the CE9178">'title' attribute here */}
      <MovieTitle title="The Matrix" />
      <MovieTitle title="Inception" />
    </div>
  );
}

Accessing Props in a Child Component

When you pass an attribute, React bundles all those attributes into a single JavaScript object called props. The child component receives this object as its first argument.

JSX
// MovieTitle.jsx
function MovieTitle(props) {
  // props is { title: "The Matrix" }
  return <h1>{props.title}</h1>;
}

Because props is just a standard object, we often use object destructuring to make our code cleaner:

JSX
function MovieTitle({ title }) {
  return <h1>{title}</h1>;
}

Worked Example: A Reusable Movie Card

Let’s advance our movie browser project. We want a MovieCard that accepts both a title and a release year.

JSX
// MovieCard.jsx
function MovieCard({ title, year }) {
  return (
    <div className="movie-card">
      <h2>{title}</h2>
      <p>Released: {year}</p>
    </div>
  );
}

// App.jsx
function App() {
  return (
    <div>
      <MovieCard title="The Matrix" year="1999" />
      <MovieCard title="Inception" year="2010" />
    </div>
  );
}

By changing the attributes in App.jsx, the MovieCard component updates automatically. This is the core of component communication in React.

Hands-on Exercise

  1. Open your project from Setting Up with Vite.
  2. Create a new component file named Greeting.jsx.
  3. Inside, create a component that accepts a name prop and renders an <h1> saying "Hello, [name]!".
  4. Import Greeting into your App.jsx and render it twice with different names (e.g., <Greeting name="Alice" />).

Common Pitfalls

  • Mutating Props: Props are read-only. Never try to reassign a prop value inside a child component (e.g., props.title = "New Title" will not work and is considered an anti-pattern). If data needs to change over time, use state, which we will cover in later lessons.
  • Forgetting Curly Braces: When passing non-string values (like numbers or booleans), you must use curly braces: <MovieCard year={1999} />. If you write year="1999", React treats it as the string "1999".
  • Case Sensitivity: Prop names are case-sensitive. If you pass movieTitle, you must access it as props.movieTitle, not props.movietitle.

Recap

We've covered the fundamentals of passing data via props. Key takeaways:

  1. Props allow parents to pass data down to children.
  2. Data flow is strictly unidirectional—always parent to child.
  3. Access props by destructuring the props object in your function signature.
  4. Keep props read-only; they are for configuration, not for internal component data storage.

Understanding these patterns is essential for managing React state management and the unidirectional data flow as your application grows in complexity.

Up next: We'll take what we've learned and build more complex, Dynamic Movie Cards that leverage these concepts to display full movie details.

Previous lessonStyling ComponentsNext lesson Dynamic Movie Cards
Back to Blog

Similar Posts

ReactReactJune 25, 20263 min read

Fetching Data from an API: A Practical React Guide

Master the fetch API in React to retrieve external data. Learn to perform asynchronous requests and store JSON responses in your component state effectively.

Read more
ReactReactJune 25, 20263 min read

Part of the course

React Fundamentals: Build Modern UIs from Scratch

beginner · Lesson 7 of 49

  1. 1

    Introduction to Component-Based Architecture

    4 min
  2. 2

    Understanding the Virtual DOM

    4 min
  3. 3

    Setting Up with Vite

    3 min

Building a Movie Filter Toggle in React: A Beginner's Guide

Master the art of UI state management by adding a filter toggle to your movie app. Learn to control list rendering using boolean state and checkbox inputs.

Read more
ReactJune 25, 20264 min read

Introduction to React State: Making Your UI Interactive

Learn how to use state in React to create dynamic interfaces. Understand why state is mutable and how useState triggers re-renders for a reactive UI.

Read more
4

Mastering JSX Syntax

4 min
  • 5

    Creating Static Components

    3 min
  • 6

    Styling Components

    3 min
  • 7

    Passing Data with Props

    3 min
  • 8

    Dynamic Movie Cards

    3 min
  • 9

    Component Composition

    3 min
  • 10

    Conditional Rendering

    3 min
  • 11

    Rendering Lists of Data

    4 min
  • 12

    The Key Prop Explained

    4 min
  • 13

    Introduction to React State

    4 min
  • 14

    Managing State with useState

    3 min
  • 15

    Building an Interactive Search Bar

    3 min
  • 16

    Handling Click Events

    4 min
  • 17

    Updating State Based on Previous State

    4 min
  • 18

    Filtering the Movie List

    3 min
  • 19

    Handling Form Submissions

    3 min
  • 20

    Controlled Components

    4 min
  • 21

    Event Bubbling and Propagation

    3 min
  • 22

    Building a Movie Filter Toggle

    3 min
  • 23

    Introduction to Side Effects

    4 min
  • 24

    useEffect Dependencies

    4 min
  • 25

    Fetching Data from an API

    3 min
  • 26

    Handling Loading States

    3 min
  • 27

    Managing Errors

    3 min
  • 28

    Cleanup Functions in useEffect

    3 min
  • 29

    Debouncing Search Input

    3 min
  • 30

    Refactoring for Clean Code

    3 min
  • 31

    Folder Structure Best Practices

    4 min
  • 32

    Extracting Custom Hooks

    3 min
  • 33

    Prop Drilling and Context API

    3 min
  • 34

    Polishing the UI

    Coming soon
  • 35

    Finalizing the Movie Browser

    Coming soon
  • 36

    Review of Component Lifecycle

    Coming soon
  • 37

    Review of State Management

    Coming soon
  • 38

    Building a Modal Component

    Coming soon
  • 39

    Introduction to PropTypes

    Coming soon
  • 40

    Performance Optimization Basics

    Coming soon
  • 41

    Handling Browser History

    Coming soon
  • 42

    Working with LocalStorage

    Coming soon
  • 43

    Building a Favorites List

    Coming soon
  • 44

    Handling Media in React

    Coming soon
  • 45

    Introduction to Testing

    Coming soon
  • 46

    Debugging React Apps

    Coming soon
  • 47

    Deployment Basics

    Coming soon
  • 48

    Using External Libraries

    Coming soon
  • 49

    Advanced

    Coming soon
  • View full course