Skip to main content

πŸ“˜ React Props β€” Complete In-Depth Theory Guide


1. Introduction

πŸ”Ή What are Props?

Props (short for β€œproperties”) are inputs passed from a parent component to a child component in React. They allow components to be:
  • Dynamic
  • Reusable
  • Configurable
πŸ‘‰ Props are read-only and cannot be modified by the receiving component.

πŸ”Ή Why Props are Important in React

Props are fundamental because they enable:
  • Component Reusability
    • Same component, different data
  • Separation of Concerns
    • Logic in parent, UI in child
  • Data Flow
    • Enables unidirectional data flow (top β†’ down)

πŸ”Ή When and Why We Use Props

Use props when:
  • You want to pass data to child components
  • You need to customize UI behavior
  • You want to share state across components
  • You are building composable UI systems

2. Concepts / Internal Workings

πŸ”Ή Unidirectional Data Flow

React follows a one-way data flow:
  • Props flow down the component tree
  • Child cannot directly modify parent data

πŸ”Ή Props are Immutable

Props are read-only objects.
πŸ‘‰ React enforces immutability to:
  • Prevent side effects
  • Ensure predictable UI updates

πŸ”Ή How Props Work Internally

Under the hood:
  1. React creates a virtual DOM element
  2. Props are stored as an object inside it
  3. During rendering:
    • React compares old vs new props (diffing)
    • Updates only what changed
Internally becomes:

πŸ”Ή Props vs State


πŸ”Ή Relationship with Other React Features

  • Hooks (useState, useEffect)
    • Props often trigger effects
  • Context API
    • Alternative to passing props deeply (prop drilling)
  • Memoization (React.memo)
    • Props are used for comparison to prevent re-renders

3. Syntax & Examples


πŸ”Ή Basic Props Passing


πŸ”Ή Destructuring Props


πŸ”Ή Passing Multiple Props


πŸ”Ή Default Props


πŸ”Ή Passing Functions as Props

πŸ‘‰ Enables child β†’ parent communication

πŸ”Ή Passing Objects & Arrays


πŸ”Ή Children Prop

πŸ‘‰ children is a special prop

πŸ”Ή Spread Props


πŸ”Ή Conditional Props


πŸ”Ή Inline Expressions


4. Edge Cases / Common Mistakes


❌ Mutating Props

βœ… Fix: Use state or callbacks

❌ Prop Drilling

πŸ‘‰ Problem: Passing props through many layers βœ… Solution:
  • Context API
  • State management (Redux, Zustand)

❌ Re-render Issues with Objects/Functions

πŸ‘‰ New object created every render β†’ unnecessary re-renders βœ… Fix:

❌ Missing Props

πŸ‘‰ Crash if name is undefined βœ… Fix:

❌ Incorrect Type Usage

Passing wrong types can break UI. βœ… Solution:
  • Use TypeScript or PropTypes

❌ Overusing Props

Too many props β†’ hard to maintain
βœ… Fix:
  • Group into objects
  • Refactor components

5. Best Practices


βœ… Keep Props Minimal

  • Pass only what is needed
  • Avoid unnecessary data

βœ… Use Destructuring

Improves readability

βœ… Use Meaningful Names


βœ… Avoid Inline Functions (When Needed)

Better:

βœ… Memoization for Performance

Use:
  • React.memo
  • useMemo
  • useCallback
To prevent unnecessary re-renders

βœ… Validate Props

Using TypeScript:

βœ… Component Composition over Props Explosion

Instead of:
Prefer:

βœ… Avoid Deep Prop Drilling

Use:
  • Context API
  • Global state management

βœ… Keep Components Pure

Props in β†’ UI out

πŸ”š Summary

Props are:
  • Immutable inputs
  • Used for component communication
  • Key to reusability and composition
Mastering props helps you:
  • Design scalable UI
  • Optimize performance
  • Write maintainable React code

πŸ“˜ React Props β€” Senior-Level Conceptual Interview Questions


1. Why are props immutable in React? What would break if they were mutable?

βœ… Strong Answer

Props are immutable to maintain predictability and consistency in rendering.

WHY:

  • React relies on pure component rendering
  • Immutability enables efficient diffing (reconciliation)
  • Prevents side effects across component boundaries
If props were mutable:
  • Child components could silently modify parent data
  • React’s Virtual DOM diffing would become unreliable
  • Debugging becomes extremely difficult due to hidden mutations

Comparison:

  • Props β†’ Immutable (controlled externally)
  • State β†’ Mutable (controlled internally)

2. How does React detect prop changes during reconciliation?

βœ… Strong Answer

React uses shallow comparison of props during reconciliation.

HOW:

  • When a component re-renders:
    • React compares previous props vs new props
    • If different β†’ re-render child
This creates a new object reference each render, so React sees it as changed.

WHY:

  • Shallow comparison is fast (O(n))
  • Deep comparison would be expensive

Optimization:

Alternative:

  • React.memo() for functional components

3. Explain prop drilling. When is it actually acceptable?

βœ… Strong Answer

Prop drilling is passing props through multiple intermediate components.

Problem:

  • Intermediate components don’t use the data
  • Leads to tight coupling and poor maintainability

When it’s OK:

  • Small component trees
  • Clear ownership of data
  • Avoids unnecessary abstraction

When NOT:

  • Deep trees
  • Frequently changing data

Alternatives:

  • Context API
  • State management libraries

4. What are the trade-offs between props and Context API?

βœ… Strong Answer

Trade-offs:

Props
  • βœ… Transparent data flow
  • ❌ Verbose (prop drilling)
Context
  • βœ… Eliminates drilling
  • ❌ Can cause unnecessary re-renders

Key Insight:

Context is not a replacement for props β€” it’s a complement

5. Why do inline objects/functions in props cause performance issues?

βœ… Strong Answer

Because they create new references on every render.
React sees:
  • Old function !== New function β†’ triggers re-render

WHY:

  • JavaScript compares objects/functions by reference

Fix:

When it matters:

  • In memoized components (React.memo)

6. How do props enable inversion of control in React?

βœ… Strong Answer

Props allow parent components to control child behavior.

Example:

Parent decides behavior:

WHY:

  • Promotes flexibility and reusability
  • Decouples logic from UI

Alternative:

  • Hardcoding logic inside component β†’ less reusable

7. What is the β€œchildren” prop and why is it powerful?

βœ… Strong Answer

children allows components to act as wrappers or layouts.

WHY powerful:

  • Enables composition over configuration
  • Avoids prop explosion

Alternative:


8. How does React.memo interact with props?

βœ… Strong Answer

React.memo prevents re-render if props haven’t changed (shallow comparison).

Pitfall:

WHY:

  • New reference each render

Fix:

  • Memoize props
  • Use custom comparison function

9. What happens when props change? Describe the full lifecycle.

βœ… Strong Answer

  1. Parent re-renders
  2. New props passed to child
  3. React compares old vs new props
  4. If changed:
    • Child re-renders
    • Effects may run (useEffect)

Important:

  • Even if props are same β†’ child may still re-render (unless memoized)

10. Can a component re-render without prop changes?

βœ… Strong Answer

Yes.

Reasons:

  • Parent re-render
  • Internal state changes
  • Context updates
Child re-renders even if name didn’t change.

Optimization:

  • React.memo

11. Why is passing large objects as props risky?

βœ… Strong Answer

  • Causes frequent re-renders
  • Harder to track changes
  • Breaks memoization

Better:

Instead of:

Trade-off:

  • Granularity vs convenience

12. How do you handle optional props safely?

βœ… Strong Answer

Use:
  • Default values
  • Type checking

WHY:

Prevents runtime errors:

13. Explain controlled vs uncontrolled behavior using props.

βœ… Strong Answer

Controlled component:
  • Parent controls value via props
Uncontrolled:
  • Component manages its own state

WHY:

  • Controlled β†’ predictable
  • Uncontrolled β†’ simpler but less control

14. What are the dangers of β€œprop explosion”?

βœ… Strong Answer

Too many props:

Problems:

  • Hard to maintain
  • Poor readability
  • Tight coupling

Solutions:

  • Group into objects
  • Use composition

15. When should you derive state from props (and when not)?

βœ… Strong Answer

Avoid:

WHY:

  • Leads to stale state
  • Sync issues

Use only when:

  • Need to transform props once

Alternative:

  • Compute directly from props
  • Use memoization

16. How do props interact with hooks like useEffect?

βœ… Strong Answer

Props can trigger effects:

WHY:

  • Dependency array watches prop changes

Pitfall:

  • Missing dependency β†’ stale data
  • Over-dependency β†’ unnecessary calls

17. What is a render prop pattern and how does it differ from normal props?

βœ… Strong Answer

A render prop is a function prop that returns JSX.

WHY:

  • Enables dynamic rendering logic

vs Normal Props:

  • Normal β†’ static data
  • Render prop β†’ dynamic UI logic

18. How would you design a highly reusable component using props?

βœ… Strong Answer

Principles:
  • Keep props minimal
  • Use children
  • Accept behavior via callbacks

WHY:

  • Flexible
  • Composable
  • Decoupled

πŸ”š Final Takeaway

Senior-level understanding of props is about:
  • Data flow architecture
  • Performance implications
  • Component design philosophy
  • Trade-offs between abstraction vs simplicity

πŸ“˜ React Props β€” Senior-Level MCQs (Deep Understanding)


1. What happens in the following scenario?

Options:

A. Child renders only once B. Child re-renders on every Parent render C. Child never re-renders D. React throws an error

βœ… Correct Answer: B

βœ” Explanation:

  • A new object is created on every render β†’ new reference
  • React sees data as changed β†’ triggers re-render

❌ Why others are wrong:

  • A: Incorrect β€” reference changes every time
  • C: Impossible unless memoized
  • D: No error here

2. What will prevent unnecessary re-renders here?

Options:

A. Wrap Child with React.memo only B. Use useMemo for config C. Use useCallback D. Nothing can prevent it

βœ… Correct Answer: B

βœ” Explanation:

  • Object literal creates new reference
  • useMemo stabilizes it

❌ Why others are wrong:

  • A: Won’t help alone (props still change)
  • C: For functions, not objects
  • D: Incorrect β€” optimization exists

3. What happens if props are mutated inside a child?

Options:

A. React prevents mutation automatically B. Parent state updates C. Silent mutation causing bugs D. Component crashes

βœ… Correct Answer: C

βœ” Explanation:

  • JS allows mutation β†’ React doesn’t block it
  • Leads to unexpected side effects

❌ Why others are wrong:

  • A: No enforcement at runtime
  • B: No automatic sync
  • D: No crash unless used incorrectly

4. Why does this component re-render?

Options:

A. React.memo doesn’t work with functions B. Function is recreated each render C. Event handlers always trigger re-render D. Memo only works with state

βœ… Correct Answer: B

βœ” Explanation:

  • New function reference each render β†’ fails shallow comparison

❌ Why others are wrong:

  • A: Memo works fine with functions
  • C: Events don’t trigger re-render by default
  • D: Memo works with props

5. What is the best fix?

Options:

A. Move function outside component B. Use useCallback C. Use useEffect D. No fix needed

βœ… Correct Answer: B

βœ” Explanation:

❌ Why others are wrong:

  • A: May break access to state
  • C: Irrelevant
  • D: Incorrect

6. What will happen?

Options:

A. Renders empty B. Throws runtime error C. React warns but works D. React auto-fills props

βœ… Correct Answer: B

βœ” Explanation:

  • user is undefined β†’ user.name crashes

❌ Why others are wrong:

  • A: No fallback
  • C: No automatic handling
  • D: React doesn’t infer props

7. What is the best fix?

Options:

A. Optional chaining B. Default props C. Both A and B D. Wrap in try-catch

βœ… Correct Answer: C

βœ” Explanation:

❌ Why others are wrong:

  • A/B alone may not fully cover
  • D: Overkill

8. What is the issue here?

Options:

A. Child won’t update B. Child always re-renders C. Props cause memory leak D. Infinite loop

βœ… Correct Answer: B

βœ” Explanation:

  • Parent state change β†’ re-render β†’ child re-renders

❌ Why others are wrong:

  • A: Incorrect
  • C/D: Not applicable

9. How to optimize the child?

Options:

A. React.memo B. useEffect C. useReducer D. useRef

βœ… Correct Answer: A


10. What happens with prop drilling?

Options:

A. Improves performance B. Increases coupling C. Reduces bugs D. Avoids re-renders

βœ… Correct Answer: B

βœ” Explanation:

  • Intermediate components depend on props unnecessarily

11. Which is better for deeply nested data?

Options:

A. Props B. Context API C. Inline functions D. useEffect

βœ… Correct Answer: B


12. What happens here?

Options:

A. Always re-renders B. Never re-renders C. Re-renders only if reference changes D. Crashes

βœ… Correct Answer: C


13. What is wrong with this pattern?

Options:

A. Nothing B. Causes stale state issues C. Causes infinite loop D. Slows rendering

βœ… Correct Answer: B

βœ” Explanation:

  • State won’t update if prop changes

14. What is the better approach?

Options:

A. useEffect sync B. Derive directly from props C. Global state D. Ignore updates

βœ… Correct Answer: B


15. Why is children preferred over multiple props?

Options:

A. Faster rendering B. Avoids prop explosion C. Required by React D. Works only in class components

βœ… Correct Answer: B


16. What happens here?

Then:

Options:

A. Props update only B. Component remounts C. No change D. Error

βœ… Correct Answer: B

βœ” Explanation:

  • Key change β†’ React treats as new component

17. Which causes unnecessary re-renders?

Options:

A. Stable primitive props B. Inline objects/functions C. useMemo values D. Static props

βœ… Correct Answer: B


18. What is the main purpose of props?

Options:

A. Manage internal state B. Enable data flow and composition C. Replace hooks D. Optimize rendering

βœ… Correct Answer: B


πŸ”š Final Insight

These questions test:
  • Reference equality vs value equality
  • Rendering behavior
  • Component design decisions
  • Performance optimization

πŸ“˜ React Props β€” Real-World Coding Problems (Senior Level)


🧩 Problem 1: Dynamic Profile Card System

πŸ“Œ Problem Statement

Build a reusable ProfileCard component that receives user data via props and renders different layouts based on user type.

πŸ”’ Constraints

  • Props: { user, variant }
  • variant can be "compact" or "detailed"
  • Must not mutate props

βœ… Expected Behavior

  • Compact β†’ name + avatar
  • Detailed β†’ name + avatar + bio + stats

⚠️ Edge Cases

  • Missing user fields
  • Unknown variant

πŸ’‘ Solution

🧠 Explanation

  • Uses default props to avoid crashes
  • Conditional rendering based on props

🧩 Problem 2: Controlled Form Input Wrapper

πŸ“Œ Problem Statement

Create an InputField component that behaves as a controlled component via props.

πŸ”’ Constraints

  • Props: { value, onChange }
  • Must not manage internal state

βœ… Expected Behavior

  • Value updates only via parent

⚠️ Edge Cases

  • Undefined value
  • onChange not passed

πŸ’‘ Solution

🧠 Explanation

  • Demonstrates controlled component via props

🧩 Problem 3: Prevent Unnecessary Re-renders

πŸ“Œ Problem Statement

Optimize a ListItem component receiving object props.

πŸ”’ Constraints

  • Must avoid unnecessary re-renders

⚠️ Edge Cases

  • Parent re-renders frequently

πŸ’‘ Solution

Parent:

🧠 Explanation

  • Combines React.memo + stable props

🧩 Problem 4: Modal with Render Props

πŸ“Œ Problem Statement

Build a modal that receives UI via a render prop.

πŸ”’ Constraints

  • Props: { render }

πŸ’‘ Solution

Usage:

🧠 Explanation

  • Demonstrates render prop pattern

🧩 Problem 5: Button with Behavior Injection

πŸ“Œ Problem Statement

Create a reusable button that receives behavior via props.

πŸ’‘ Solution

🧠 Explanation

  • Shows inversion of control

🧩 Problem 6: Deep Prop Drilling Refactor

πŸ“Œ Problem Statement

Refactor a deeply nested component passing props through 4 levels.

πŸ”’ Constraints

  • Avoid prop drilling

πŸ’‘ Solution

Use Context:

🧠 Explanation

  • Avoids unnecessary prop passing

🧩 Problem 7: Derived State Anti-pattern Fix

πŸ“Œ Problem Statement

Fix component syncing state from props incorrectly.

πŸ’‘ Solution

🧠 Explanation

  • Avoids stale state issues

🧩 Problem 8: Safe Optional Props Rendering

πŸ“Œ Problem Statement

Render optional nested data safely.

πŸ’‘ Solution


🧩 Problem 9: Generic Table Component

πŸ“Œ Problem Statement

Build a table that receives columns and data via props.

πŸ”’ Constraints

  • Dynamic columns

πŸ’‘ Solution


🧩 Problem 10: Prevent Function Prop Re-Creation

πŸ“Œ Problem Statement

Optimize function props in a list.

πŸ’‘ Solution


🧩 Problem 11: Compound Component Pattern

πŸ“Œ Problem Statement

Create a Tabs system using props + children.

πŸ’‘ Solution


🧩 Problem 12: Prop Validation with TypeScript

πŸ“Œ Problem Statement

Ensure correct prop types.

πŸ’‘ Solution


🧩 Problem 13: Conditional Rendering Based on Props

πŸ“Œ Problem Statement

Render loading or content.

πŸ’‘ Solution


🧩 Problem 14: Reusable Layout Wrapper

πŸ“Œ Problem Statement

Create layout using children.

πŸ’‘ Solution


🧩 Problem 15: Key Prop Behavior

πŸ“Œ Problem Statement

Explain remount behavior when key changes.

πŸ’‘ Explanation

  • Changing key forces remount β†’ resets state

🧩 Problem 16: Memoization Pitfall

πŸ“Œ Problem Statement

Fix unnecessary re-renders with nested props.

πŸ’‘ Solution

  • Normalize props
  • Avoid passing full objects

🧩 Problem 17: Dynamic Theme Injection

πŸ“Œ Problem Statement

Pass theme via props.

πŸ’‘ Solution


🧩 Problem 18: Higher-Order Component with Props

πŸ“Œ Problem Statement

Wrap component and pass extra props.

πŸ’‘ Solution


🧩 Problem 19: Prop Normalization Layer

πŸ“Œ Problem Statement

Normalize inconsistent API response props.

πŸ’‘ Solution


🧩 Problem 20: Performance Audit Scenario

πŸ“Œ Problem Statement

Optimize a large list receiving props.

πŸ’‘ Solution

  • Use React.memo
  • Virtualization (React Window)
  • Stable props

πŸ”š Final Takeaway

These problems test:
  • Real-world prop usage
  • Performance optimization
  • Architecture decisions
  • Debugging mindset

πŸ› οΈ React Props β€” Senior-Level Debugging Challenges (Production Scenarios)


🧩 1. Infinite Re-render due to Derived State

❌ Buggy Code

πŸ” What’s Wrong

  • Effect depends on count but sets count β†’ infinite loop

❓ WHY it happens

  • Changing count triggers effect again β†’ loop

βœ… Fix

🧠 Best Practice

  • Avoid syncing props to state unless necessary

🧩 2. React.memo Not Working

❌ Buggy Code

πŸ” What’s Wrong

  • Inline object causes new reference each render

❓ WHY

  • Shallow comparison fails

βœ… Fix

🧠 Best Practice

  • Stabilize object/array props

🧩 3. Unexpected Undefined Crash

❌ Buggy Code

πŸ” What’s Wrong

  • user may be undefined

❓ WHY

  • Props not guaranteed unless validated

βœ… Fix

🧠 Best Practice

  • Always guard optional props

🧩 4. Function Prop Causing Re-renders

❌ Buggy Code

πŸ” What’s Wrong

  • New function every render

❓ WHY

  • Breaks memoization

βœ… Fix

🧠 Best Practice

  • Use useCallback for stable handlers

🧩 5. Prop Mutation Bug

❌ Buggy Code

πŸ” What’s Wrong

  • Mutating props

❓ WHY

  • Breaks React’s data flow

βœ… Fix

🧠 Best Practice

  • Treat props as immutable

🧩 6. Stale Closure with Props

❌ Buggy Code

πŸ” What’s Wrong

  • delay is stale

❓ WHY

  • Closure captures initial value

βœ… Fix

🧠 Best Practice

  • Always include props in dependencies

🧩 7. Over-rendering Child Components

❌ Buggy Code

Parent re-renders frequently.

πŸ” Issue

  • Child re-renders unnecessarily

❓ WHY

  • No memoization

βœ… Fix

🧠 Best Practice

  • Memoize pure components

🧩 8. Incorrect Key Causing State Reset

❌ Buggy Code

πŸ” What’s Wrong

  • Index as key

❓ WHY

  • Order changes β†’ wrong reconciliation

βœ… Fix

🧠 Best Practice

  • Use stable unique keys

🧩 9. Conditional Props Breaking UI

❌ Buggy Code

πŸ” What’s Wrong

  • Passing string instead of boolean

❓ WHY

  • "true" is truthy but incorrect type

βœ… Fix


🧩 10. Spreading Unnecessary Props

❌ Buggy Code

πŸ” Issue

  • Passing unused props

❓ WHY

  • Increases coupling, risk of bugs

βœ… Fix


🧩 11. Breaking Controlled Component

❌ Buggy Code

πŸ” Issue

  • Missing onChange

❓ WHY

  • Becomes read-only

βœ… Fix


🧩 12. Recomputing Expensive Props

❌ Buggy Code

πŸ” Issue

  • Expensive computation every render

❓ WHY

  • Function runs each render

βœ… Fix


🧩 13. Nested Object Prop Issue

❌ Buggy Code

πŸ” Issue

  • Deep object recreated

❓ WHY

  • Breaks memo

βœ… Fix

  • Lift and memoize object

🧩 14. Children Misuse

❌ Buggy Code

πŸ” Issue

  • Reassigning props

βœ… Fix


🧩 15. Props Not Updating in Child

❌ Buggy Code

πŸ” Issue

  • Not synced with prop changes

βœ… Fix

  • Use props directly OR sync via effect

🧩 16. Boolean Prop Misinterpretation

❌ Buggy Code

πŸ” Issue

  • String is truthy

βœ… Fix


🧩 17. Overusing Props Instead of Composition

❌ Buggy Code

πŸ” Issue

  • Rigid API

βœ… Fix


🧩 18. Missing Dependency Causing Buggy UI

❌ Buggy Code

πŸ” Issue

  • Doesn’t react to prop change

βœ… Fix


πŸ”š Final Takeaway

These bugs reflect real production issues:
  • Reference equality pitfalls
  • Stale closures
  • Improper memoization
  • Incorrect assumptions about props

πŸ—οΈ React Props β€” Real-World Machine Coding Problems (Senior / Architect Level)

These are production-grade problems designed to test:
  • Component architecture
  • Data flow via props
  • Performance & scalability
  • Real-world trade-offs

🧩 1. Configurable Data Table (Enterprise Grid)

πŸ“Œ Requirements

  • Render dynamic table using props:
    • columns, data, renderCell, sortConfig
  • Support:
    • Sorting
    • Custom cell rendering
    • Column visibility toggle

πŸ–₯️ UI Behavior

  • Click column header β†’ sort
  • Toggle columns β†’ hide/show instantly

πŸ”„ Data Flow

  • Parent owns data & sorting state
  • Table receives everything via props

⚠️ Edge Cases

  • Empty data
  • Missing keys
  • Large datasets

⚑ Performance

  • Virtualization (react-window)
  • Memoized rows

πŸ—οΈ Architecture

  • Table
  • TableRow
  • TableCell

🧠 Approach

  1. Normalize columns
  2. Pass render functions as props
  3. Memoize rows

🧩 2. Headless Modal System

πŸ“Œ Requirements

  • Build a modal with:
    • isOpen, onClose, children
  • No styling (headless)

πŸ–₯️ UI Behavior

  • Close on overlay click / ESC

πŸ”„ Data Flow

  • Parent controls open/close

⚠️ Edge Cases

  • Multiple modals
  • Focus trap

⚑ Performance

  • Lazy mount/unmount

πŸ—οΈ Architecture

  • Modal
  • Portal

🧠 Approach

  • Use children for flexibility
  • Use props for behavior injection

🧩 3. Multi-Step Form Wizard

πŸ“Œ Requirements

  • Steps passed as props:
    • steps, currentStep, onNext, onBack

πŸ–₯️ UI Behavior

  • Navigate steps
  • Validate before next

πŸ”„ Data Flow

  • Central form state in parent

⚠️ Edge Cases

  • Skip steps
  • Validation errors

⚑ Performance

  • Avoid re-rendering all steps

πŸ—οΈ Architecture

  • Wizard
  • Step

🧠 Approach

  • Render active step only
  • Pass handlers via props

🧩 4. Reusable Dropdown with Custom Rendering

πŸ“Œ Requirements

  • Props:
    • options, renderOption, onSelect

πŸ–₯️ UI Behavior

  • Keyboard navigation
  • Custom UI per option

⚠️ Edge Cases

  • Empty list
  • Duplicate values

⚑ Performance

  • Debounced filtering

🧠 Approach

  • Render prop for flexibility

🧩 5. Infinite Scroll Feed

πŸ“Œ Requirements

  • Props:
    • fetchData, renderItem

πŸ–₯️ UI Behavior

  • Load more on scroll

πŸ”„ Data Flow

  • Parent handles API

⚠️ Edge Cases

  • Duplicate fetch
  • End of list

⚑ Performance

  • Intersection Observer

🧠 Approach

  • Controlled via props

🧩 6. Theme System (Dynamic Styling)

πŸ“Œ Requirements

  • Pass theme via props
  • Support light/dark

⚠️ Edge Cases

  • Missing theme keys

⚑ Performance

  • Memoize theme object

🧠 Approach

  • Theme provider or prop drilling trade-off

🧩 7. Form Builder (Schema-driven UI)

πŸ“Œ Requirements

  • Props:
    • schema, onSubmit

πŸ–₯️ UI Behavior

  • Dynamically render inputs

⚠️ Edge Cases

  • Unknown field types

⚑ Performance

  • Lazy render sections

🧠 Approach

  • Map schema β†’ components

🧩 8. Drag & Drop List

πŸ“Œ Requirements

  • Props:
    • items, onReorder

⚠️ Edge Cases

  • Rapid drag events

⚑ Performance

  • Avoid full list re-render

🧠 Approach

  • Stable keys
  • Memoized items

🧩 9. Notification System

πŸ“Œ Requirements

  • Props:
    • notifications, onDismiss

πŸ–₯️ UI Behavior

  • Auto-dismiss

⚠️ Edge Cases

  • Duplicate notifications

🧠 Approach

  • Controlled list via props

🧩 10. Search with Debounced Input

πŸ“Œ Requirements

  • Props:
    • onSearch

⚑ Performance

  • Debounce input

🧩 11. Reusable Card System (Composable UI)

πŸ“Œ Requirements

  • Use children for layout slots

🧠 Approach

  • Composition over props explosion

🧩 12. Chart Wrapper (Reusable Visualization)

πŸ“Œ Requirements

  • Props:
    • data, config

⚠️ Edge Cases

  • Empty dataset

⚑ Performance

  • Memoized transformations

🧩 13. Permission-based Rendering

πŸ“Œ Requirements

  • Props:
    • permissions, children

🧠 Approach


🧩 14. Lazy Image Component

πŸ“Œ Requirements

  • Props:
    • src, placeholder

⚑ Performance

  • Intersection Observer

🧩 15. File Upload Component

πŸ“Œ Requirements

  • Props:
    • onUpload, accept

⚠️ Edge Cases

  • Invalid file types

🧩 16. Pagination Component

πŸ“Œ Requirements

  • Props:
    • page, totalPages, onChange

🧩 17. Headless Tooltip System

πŸ“Œ Requirements

  • Props:
    • content, children

🧩 18. Virtualized List

πŸ“Œ Requirements

  • Props:
    • items, rowHeight

⚑ Performance

  • Render visible rows only

🧩 19. Undo/Redo System

πŸ“Œ Requirements

  • Props:
    • state, onUndo, onRedo

🧩 20. Live Collaborative Cursor Tracker

πŸ“Œ Requirements

  • Props:
    • users, positions

⚠️ Edge Cases

  • Rapid updates

⚑ Performance

  • Throttle updates

πŸ”š Final Architect Insight

These problems test:
  • Prop-driven architecture
  • Component composition vs configuration
  • Performance tuning
  • Scalable design patterns

πŸ“˜ React Props β€” FAANG-Level Interview Questions (Senior Depth)


1. How would you design a component API using props for long-term scalability?

πŸ” Follow-up

  • How do you prevent prop explosion?
  • When would you switch to composition?

βœ… Strong Answer

  • Start with minimal, explicit props
  • Prefer composition (children) over configuration
  • Group related props into objects when needed
  • Design for extensibility without breaking changes

WHY:

  • Reduces coupling
  • Improves flexibility

❌ Weak Answer

  • β€œJust add more props as needed” πŸ‘‰ Fails because it ignores scalability and API design

2. Explain how React decides whether to re-render a component based on props.

πŸ” Follow-up

  • How does React.memo change this?
  • What are its limitations?

βœ… Strong Answer

  • By default, React re-renders when parent renders
  • React.memo does shallow comparison of props

Key Insight:

  • Reference equality matters

❌ Weak Answer

  • β€œReact only re-renders when props change” πŸ‘‰ Incorrect β€” parent re-render triggers child too

3. You notice a component re-rendering frequently despite unchanged data. How do you debug it?

πŸ” Follow-up

  • What tools would you use?

βœ… Strong Answer

  • Check:
    • Inline objects/functions
    • Parent re-renders
    • Missing memoization
  • Use:
    • React DevTools Profiler

❌ Weak Answer

  • β€œAdd React.memo everywhere” πŸ‘‰ Over-optimization without understanding cause

4. When would you avoid passing an object as a prop?

πŸ” Follow-up

  • When is it acceptable?

βœ… Strong Answer

  • Avoid when:
    • Object recreated each render
    • Component is memoized
  • Acceptable when:
    • Stable reference (useMemo)
    • Small apps

❌ Weak Answer

  • β€œObjects are always bad” πŸ‘‰ Oversimplification

5. Design a reusable table component. What props would you expose?

πŸ” Follow-up

  • How do you support custom rendering?

βœ… Strong Answer

  • Props:
    • data, columns, renderCell
  • Use render props for flexibility

❌ Weak Answer

  • β€œJust pass data and map it” πŸ‘‰ Not scalable or flexible

6. How do you handle deeply nested data without prop drilling?

πŸ” Follow-up

  • Trade-offs of Context API?

βœ… Strong Answer

  • Use Context for global/shared data
  • Avoid overuse (causes re-renders)

❌ Weak Answer

  • β€œAlways use Context” πŸ‘‰ Ignores trade-offs

7. What are the risks of syncing props to state?

πŸ” Follow-up

  • When is it justified?

βœ… Strong Answer

  • Risks:
    • Stale state
    • Sync bugs
  • Use only for:
    • Derived/controlled transformations

❌ Weak Answer

  • β€œIt’s fine to copy props into state” πŸ‘‰ Leads to bugs

8. How would you design a component that allows behavior injection?

πŸ” Follow-up

  • Compare with HOCs

βœ… Strong Answer

  • Use function props (callbacks)

❌ Weak Answer

  • β€œHardcode logic” πŸ‘‰ Not reusable

9. Why does this cause unnecessary re-renders?

πŸ” Follow-up

  • How do you fix it?

βœ… Strong Answer

  • New object reference each render
Fix:

❌ Weak Answer

  • β€œReact is inefficient” πŸ‘‰ Misunderstanding core behavior

10. How do you decide between props vs global state?

πŸ” Follow-up

  • What are scaling concerns?

βœ… Strong Answer

  • Props:
    • Local, predictable
  • Global state:
    • Shared, complex

❌ Weak Answer

  • β€œUse Redux for everything” πŸ‘‰ Overengineering

11. What is the role of children in API design?

πŸ” Follow-up

  • When not to use it?

βœ… Strong Answer

  • Enables composition
  • Avoids rigid APIs

❌ Weak Answer

  • β€œIt’s just for nesting” πŸ‘‰ Misses design importance

12. A component is slow due to heavy prop computation. How do you optimize?

πŸ” Follow-up

  • Trade-offs of memoization?

βœ… Strong Answer

  • Use useMemo
  • Move computation outside render

❌ Weak Answer

  • β€œUse useEffect” πŸ‘‰ Wrong tool

13. Explain how prop changes trigger effects.

πŸ” Follow-up

  • What if dependency is missing?

βœ… Strong Answer

  • useEffect runs when dependencies change

❌ Weak Answer

  • β€œEffects run on every render” πŸ‘‰ Incorrect

14. How would you design a headless component using props?

πŸ” Follow-up

  • Why is this pattern useful?

βœ… Strong Answer

  • Logic via props, UI via children

❌ Weak Answer

  • β€œJust build UI directly” πŸ‘‰ Not reusable

15. How do you prevent unnecessary prop spreading?

πŸ” Follow-up

  • When is spreading useful?

βœ… Strong Answer

  • Explicit props preferred
  • Spread only for wrappers

❌ Weak Answer

  • β€œAlways use spread” πŸ‘‰ Risky

16. What happens when a key changes but props don’t?

πŸ” Follow-up

  • Real-world use case?

βœ… Strong Answer

  • Component remounts β†’ state reset

❌ Weak Answer

  • β€œNothing changes” πŸ‘‰ Incorrect

17. How do you handle optional props in large systems?

πŸ” Follow-up

  • Type safety strategies?

βœ… Strong Answer

  • Default values
  • TypeScript

❌ Weak Answer

  • β€œJust check manually” πŸ‘‰ Not scalable

18. Describe a real-world bug caused by props and how you’d fix it.

πŸ” Follow-up

  • How to prevent it?

βœ… Strong Answer

  • Example:
    • Inline object β†’ re-render loop
  • Fix:
    • Memoization

❌ Weak Answer

  • β€œI’d debug in console” πŸ‘‰ Lacks depth

πŸ” Follow-up

  • Metrics you’d track?

βœ… Strong Answer

  • Use Profiler
  • Check:
    • Re-render frequency
    • Prop stability

❌ Weak Answer

  • β€œRewrite everything” πŸ‘‰ Unrealistic

πŸ”š Final Interview Insight

At FAANG level, props questions test:
  • Architectural thinking
  • Trade-offs (simplicity vs scalability)
  • Performance awareness
  • Debugging intuition