React/Components/Lesson 04
Props
30 min·theory
This chapter
2/4
JavaScript
Props
💡 Why should you learn this?
🎯
It is the foundation of data communication between parent and child components.
💼
The same component can be reused with different data.
⚡
It is the most important concept in React development.
🏢 실무에서는
In real-world projects, a Button component receives label, color, and size as props to create various buttons. A UserCard component receives a name, email, and photo as props to display multiple user cards.
Props — A package sent from parent to child
Real-world analogy: A delivery package
A parent component sends a package of data to its child.
The child receives the package and uses it, but cannot change its contents.
Key characteristics
- ▸One-way: parent → child only (child → parent is done via callback functions)
- ▸Read-only: child components cannot directly modify props
- ▸Any value: strings, numbers, functions, and even components can be passed
Usage
💡 💡 Props tips
- ▸Destructuring: use the
({ name, age })pattern - ▸Optional: mark optional props with
? - ▸extends: inherit HTML attributes (
React.InputHTMLAttributes) - ▸React 19: use
use(Context)instead of props drilling
This concept is fundamental to React component development. Understand React's declarative UI paradigm, and clearly distinguish the difference between props and state. A component should behave like a pure function — always returning the same output (JSX) for the same input (props).
⚛️ React pattern — Props
Learn step by step how Props are used in React, with code examples.
1
🧩
1. Define a component
A function is a component
function Greeting({ name }) {
return <h1>Hello, {name}!</h1>;
}
↓
2
📤
2. Pass Props
One-way data flow from parent → child
<Greeting name="Hong Gil-dong" />
↓
3
🔁
3. Reuse
Same component, rendered multiple times with different props
<Greeting name="Alice" />
<Greeting name="Bob" />
↓
4
💡
4. One-way data flow
When a child needs to update the parent's state, it receives a callback function via props
📤 Props — passing data from parent to child
Edit the code directly and it will be reflected automatically after 0.7 seconds. Runs instantly in the browser using React 18 + Babel.
🖥️ Result — rendered React component
✏️ React 코드 수정하기 (클릭해서 열기)
⚛️ React 18 + Babel Standalone — see the result first, then edit the code yourself.
Check quiz
What happens when you try to modify props inside a child component?
Read this first: Component Basics
Up next: Conditional Rendering