๐Ÿ“ฆ Understanding Props in React (Beginner-Friendly Guide)

If you’re learning React, you might have seen the word “props” and wondered what it means. Don’t worry! In this blog, weโ€™ll understand props in the easiest way possible. Think of it like this:

๐Ÿง  What are Props?

๐Ÿ‘‰ Props means properties.
๐Ÿ‘‰…


This content originally appeared on DEV Community and was authored by Himanay Khajuria

If you're learning React, you might have seen the word "props" and wondered what it means. Don't worry! In this blog, weโ€™ll understand props in the easiest way possible. Think of it like this:

๐Ÿง  What are Props?

๐Ÿ‘‰ Props means properties.

๐Ÿ‘‰ They are used to pass data from one component to another in React.

๐Ÿ‘‰ Just like we pass ingredients to a recipe, we pass data (props) to a React component.

๐Ÿงƒ Simple Analogy: Juice Shop

Imagine you own a juice shop. When someone places an order, they tell you the flavor they want โ€“ like mango, orange, or apple. You then prepare the juice using that flavor.

In React, the juice shop is your component and the flavor is the prop.

๐Ÿ› ๏ธ Simple Example: Passing a Name

Letโ€™s create a small app that says hello to different people.

Step 1: Create a Welcome component:

src>components>Welcome.jsx

import React from 'react'

function Welcome(props) {
  return <h2>Hello, {props.name}!</h2>;
}

export default Welcome

Here:

๐Ÿ‘‰ Welcome is a component

๐Ÿ‘‰ It receives props as an argument

๐Ÿ‘‰ We access the name using props.name

Step 2: Use Welcome component and pass props:

src>App.jsx

import React from 'react'

function App() {
  return (
    <div>
      <Welcome name="Himanay" />
      <Welcome name="Aarav" />
      <Welcome name="Emma" />
    </div>
  );
}

export default App

๐Ÿ‘‰ We are using <Welcome /> three times

๐Ÿ‘‰ Each time, we pass a different name

๐Ÿ‘‰ props.name will be "Himanay", "Aarav", "Emma" in each one

Output:

Hello, Himanay!
Hello, Aarav!
Hello, Emma!

๐ŸŽ‰ You just used props to pass data to a component!

๐Ÿ“ฆ Little Complex Example: Passing an Object

Now letโ€™s say we want to show a userโ€™s profile with a name and an age.

Step 1: Create a Profile component:

src>components>Profile.jsx

import React from 'react'

function Profile(props) {
  return (
    <div>
      <h3>Name: {props.user.name}</h3>
      <p>Age: {props.user.age}</p>
    </div>
  );
}

export default Profile

๐Ÿ‘‰ props.user is an object

๐Ÿ‘‰ We use props.user.name and props.user.age to show the data

Step 2: Use the Profile component:

src>App.jsx

import React from 'react'

function App() {
  const user1 = { name: "Himanay", age: 28 };
  const user2 = { name: "Sophia", age: 22 };

  return (
    <div>
      <Profile user={user1} />
      <Profile user={user2} />
    </div>
  );
}

export default App

๐Ÿง  We created two user objects and passed them as props

๐Ÿง  Inside the Profile component, we used that data to show profile info

Output:

Name: Himanay
Age: 28

Name: Sophia
Age: 22

๐Ÿงผ Clean Tip: Destructuring Props

To make your code cleaner, you can also destructure props like this:

function Welcome({ name }) {
  return <h2>Hello, {name}!</h2>;
}

And:

function Profile({ user }) {
  return (
    <div>
      <h3>Name: {user.name}</h3>
      <p>Age: {user.age}</p>
    </div>
  );
}

๐Ÿ‘‰ This helps avoid writing props. again and again.

๐Ÿ” Recap

โœ… Props help us pass data from one component to another

โœ… Props are read-only, we cannot change them inside the component

โœ… You can pass strings, numbers, arrays, objects, even functions as props

โœ… Use destructuring to write cleaner code

โœ… Final Thoughts

Learning props is a big step in React. It helps you build reusable and dynamic components. Start small like we did here, and then build more complex UIs using the same idea.

If you understood this, give yourself a high five! ๐Ÿ–๏ธ

Now go ahead and try making your own components using props in CodeAcademix or any React app.

Happy Coding! ๐Ÿ’ปโœจ

Written by Himanay Khajuria


This content originally appeared on DEV Community and was authored by Himanay Khajuria


Print Share Comment Cite Upload Translate Updates
APA

Himanay Khajuria | Sciencx (2025-08-06T10:59:25+00:00) ๐Ÿ“ฆ Understanding Props in React (Beginner-Friendly Guide). Retrieved from https://www.scien.cx/2025/08/06/%f0%9f%93%a6-understanding-props-in-react-beginner-friendly-guide/

MLA
" » ๐Ÿ“ฆ Understanding Props in React (Beginner-Friendly Guide)." Himanay Khajuria | Sciencx - Wednesday August 6, 2025, https://www.scien.cx/2025/08/06/%f0%9f%93%a6-understanding-props-in-react-beginner-friendly-guide/
HARVARD
Himanay Khajuria | Sciencx Wednesday August 6, 2025 » ๐Ÿ“ฆ Understanding Props in React (Beginner-Friendly Guide)., viewed ,<https://www.scien.cx/2025/08/06/%f0%9f%93%a6-understanding-props-in-react-beginner-friendly-guide/>
VANCOUVER
Himanay Khajuria | Sciencx - » ๐Ÿ“ฆ Understanding Props in React (Beginner-Friendly Guide). [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/08/06/%f0%9f%93%a6-understanding-props-in-react-beginner-friendly-guide/
CHICAGO
" » ๐Ÿ“ฆ Understanding Props in React (Beginner-Friendly Guide)." Himanay Khajuria | Sciencx - Accessed . https://www.scien.cx/2025/08/06/%f0%9f%93%a6-understanding-props-in-react-beginner-friendly-guide/
IEEE
" » ๐Ÿ“ฆ Understanding Props in React (Beginner-Friendly Guide)." Himanay Khajuria | Sciencx [Online]. Available: https://www.scien.cx/2025/08/06/%f0%9f%93%a6-understanding-props-in-react-beginner-friendly-guide/. [Accessed: ]
rf:citation
» ๐Ÿ“ฆ Understanding Props in React (Beginner-Friendly Guide) | Himanay Khajuria | Sciencx | https://www.scien.cx/2025/08/06/%f0%9f%93%a6-understanding-props-in-react-beginner-friendly-guide/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.