MSK Institute LogoMSK.Institute
HomeCourses
Book Free Demo➔Sign In
Free Demo➔
MSK Institute LogoMSK.Institute

Leading computer training academy in Shikohabad for software engineering, Python, web development, and digital literacy.

ISO 9001:2015 Certified Center
Follow & Connect
4.9

Programs & Admissions

  • All CoursesCatalog
  • Learning PathsRoadmaps
  • Student ProjectsShowcase
  • Live Classes & ScheduleLive
  • Upcoming Batches
  • Campuses & LocationsHub
  • Verify Certificates
  • Book Free Demo Class

Resources & Tools

  • Free Online Mock TestsAll Tests
  • NIELIT CCC Mock TestFree
  • Course & Career FinderQuiz
  • Study Material Hub
  • All MSK ToolsHub
  • Keyboard ShortcutsNew
  • TypeQuest Speed LabTyping
  • MSK Code PlaygroundCode
  • Interactive Tutorials
  • Quick Cheatsheets

Institute & Contact

  • About MSK Institute
  • Careers & InternshipsHiring
  • Publications & Blogs
  • Gali No. 3, Near Gyan Jyoti Public School,
    Adarsh Nagar, Shikohabad, Uttar Pradesh 283135
  • +91 83930 42166
  • mskshikohabad@gmail.com
  • Hours:Mon – Sat: 8:00 AM – 7:00 PM | Sun: 10:00 AM – 2:00 PM
  • 4.9 ★(38 Google Reviews)
© 2026 MSK Institute. All rights reserved.•Privacy Policy•Terms of Service•Disclaimer•Contact Us

Shikohabad's Leading Computer & Coding Academy

Home
Courses
Live
Material
Component Props and Read-Only Data Flow0%
Study Materials
React.js for BeginnersProgress 0%
1.1Why React and Single-Page Architecture1.2Setting Up Modern React with Vite1.3React Project Directory Structure and Entry Points1.4Virtual DOM and React Render Cycle Explained
3.1Functional Components and Declarative UI3.2Component Props and Read-Only Data Flow3.3Destructuring Props and Default Prop Values3.4Passing Children and Composing Components
HomeTutorialsReact.js for BeginnersComponent Props and Read-Only Data Flow
Destructuring Props and Default Prop Values

Component Props and Read-Only Data Flow

Beginner12 min read•Updated: 2026-11-18•By Er. Sumit Kumar (MSK Institute)
Study MaterialsCheatsheet

1. What Are Props?

In React, props (short for "properties") are the mechanism by which components communicate with each other. Just as HTML elements accept attributes to customize their behavior (<a href="https://example.com">), React components accept props passed down from parent components.

Props can be any valid JavaScript value: strings, numbers, booleans, objects, arrays, functions (callbacks), or even other React elements.

1// Parent component passing props
2function Dashboard() {
3 return (
4 <div className="dashboard-grid">
5 <UserCard
6 name="Ananya Roy"
7 role="Frontend Architect"
8 yearsExperience={6}
9 isActive={true}
10 />
11 </div>
12 );
13}
14 
15// Child component receiving props object
16function UserCard(props) {
17 return (
18 <div className="card">
19 <h3>{props.name}</h3>
20 <p>Role: {props.role}</p>
21 <p>Experience: {props.yearsExperience} years</p>
22 <span className={props.isActive ? 'badge-green' : 'badge-gray'}>
23 {props.isActive ? 'Active' : 'Offline'}
24 </span>
25 </div>
26 );
27}

2. Unidirectional Top-Down Data Flow

React enforces strict unidirectional (one-way) data binding:

  • Data flows strictly from parent components down to child components.
  • A child component has no built-in way to directly mutate or reassign the props given to it by its parent.
  • If a child needs to inform the parent of an event or change, the parent passes a callback function down as a prop, which the child invokes.
1Parent Component (Source of Truth: state = "dark")
2 │
3 ▼ (passes prop theme="dark")
4Child Component (Renders UI based on theme prop)

3. Props are Read-Only (Immutable)

A cardinal rule in React engineering is: Components must never mutate their own props.

In JavaScript terms, props are treated as frozen, read-only values:

1// ❌ Anti-pattern: Modifying props directly is forbidden!
2function Profile(props) {
3 props.name = props.name.toUpperCase(); // Mutates prop object!
4 props.viewCount += 1; // Mutates prop object!
5 
6 return <div>{props.name} ({props.viewCount})</div>;
7}
8 
9// ✅ Correct Pattern: Derive new values or declare local variables
10function Profile(props) {
11 const formattedName = props.name.toUpperCase();
12 const nextCount = props.viewCount + 1;
13 
14 return <div>{formattedName} ({nextCount})</div>;
15}

If React permitted components to modify incoming props, child components could unexpectedly corrupt parent data structures, creating chaotic debugging nightmares across large applications.

4. Passing Non-String Props

Remember to enclose non-string values (numbers, booleans, objects, arrays) in curly braces:

1// Strings can use regular quotes
2<Badge text="Pro Member" />
3 
4// Numbers, booleans, objects, and arrays MUST use curly braces
5<Badge count={42} isVerified={true} settings={{ theme: 'dark' }} tags={['js', 'react']} />

Interactive Quiz• Knowledge Check

Practice Quiz

Question 1
What are props in React?
Question 2
Why is mutating a prop directly inside a child component forbidden in React?
Question 3
How should a child component inform its parent that a user clicked a button?
Question 4
Which prop assignment passes the number 25 as an actual JavaScript numeric type?
Question 5
What data types can be passed as props in React?
Next Lesson

Destructuring Props and Default Prop Values

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Related Lessons

Previous LessonNext Lesson
Functional Components and Declarative UIDestructuring Props and Default Prop Values

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

Mentor-Led Practical Training

Master React.js for Beginners with Hands-On Projects

Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.

View Full CourseBook Free Demo
PreviousNext
PreviousPrevNext