Props in React
📘 React.js
👁 47 views
📅 Nov 05, 2025
⏱ Estimated reading time: 2 min
Props (short for properties) are used to pass data from one component to another. They allow components to be dynamic and reusable.
What are Props?
-
Props are read-only
-
Passed from parent to child
-
Used to customize components
Usage:
Why Use Props?
-
Reuse components with different data
-
Keep components flexible
-
Separate logic and UI
Passing Multiple Props
Props with Different Data Types
-
Strings →
"text" -
Numbers / booleans →
{}
Props Destructuring
Instead of:
Use:
Default Props
Provide default values if props are missing.
Props are Read-Only
❌ Incorrect:
✅ Correct:
-
Props should never be modified
-
Use state if data needs to change
Passing Components as Props (Children)
Usage:
Props vs State
| Props | State |
|---|---|
| Passed from parent | Managed inside component |
| Read-only | Can be updated |
| Makes components reusable | Manages dynamic data |
Key Points
-
Props pass data to components
-
They are immutable
-
Destructuring improves readability
-
childrenis a special prop
🔒 Some advanced sections are available for Registered Members
Register Now
Register Now
Share this Post
← Back to Tutorials