๐ 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
๐น 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.- Prevent side effects
- Ensure predictable UI updates
๐น How Props Work Internally
Under the hood:- React creates a virtual DOM element
- Props are stored as an object inside it
-
During rendering:
- React compares old vs new props (diffing)
- Updates only what changed
๐น Props vs State
| Feature | Props | State |
|---|---|---|
| Ownership | Parent | Component itself |
| Mutability | Immutable | Mutable |
| Purpose | Pass data | Manage internal data |
๐น 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
๐น Passing Objects & Arrays
๐น Children Prop
children is a special prop
๐น Spread Props
๐น Conditional Props
๐น Inline Expressions
4. Edge Cases / Common Mistakes
โ Mutating Props
โ Prop Drilling
- Context API
- State management (Redux, Zustand)
โ Re-render Issues with Objects/Functions
โ Missing Props
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- Group into objects
- Refactor components
5. Best Practices
โ Keep Props Minimal
- Pass only what is needed
- Avoid unnecessary data
โ Use Destructuring
โ Use Meaningful Names
โ Avoid Inline Functions (When Needed)
โ Memoization for Performance
Use:React.memouseMemouseCallback
โ Validate Props
Using TypeScript:โ Component Composition over Props Explosion
Instead of:โ 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
- 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
- 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
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
| Props | Context |
|---|---|
| Explicit | Implicit |
| Easy to trace | Harder to debug |
| Good for local data | Good for global/shared data |
Trade-offs:
Props- โ Transparent data flow
- โ Verbose (prop drilling)
- โ Eliminates drilling
- โ Can cause unnecessary re-renders
Key Insight:
Context is not a replacement for props โ itโs a complement5. Why do inline objects/functions in props cause performance issues?
โ Strong Answer
Because they create new references on every render.- 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:
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
- Parent re-renders
- New props passed to child
- React compares old vs new props
-
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
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:
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
- 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
dataas 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 withReact.memo only
B. Use useMemo for config
C. Use useCallback
D. Nothing can prevent it
โ Correct Answer: B
โ Explanation:
- Object literal creates new reference
useMemostabilizes 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. UseuseCallback
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:
useris undefined โuser.namecrashes
โ 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?
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 reusableProfileCard component that receives user data via props and renders different layouts based on user type.
๐ Constraints
- Props:
{ user, variant } variantcan 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 anInputField 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 aListItem component receiving object props.
๐ Constraints
- Must avoid unnecessary re-renders
โ ๏ธ Edge Cases
- Parent re-renders frequently
๐ก Solution
๐ง 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
๐ง 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 aTabs 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
keyforces 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
countbut setscountโ infinite loop
โ WHY it happens
- Changing
counttriggers 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
usermay 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
useCallbackfor 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
delayis stale
โ WHY
- Closure captures initial value
โ Fix
๐ง Best Practice
- Always include props in dependencies
๐งฉ 7. Over-rendering Child Components
โ Buggy Code
๐ 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
TableTableRowTableCell
๐ง Approach
- Normalize columns
- Pass render functions as props
- 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
ModalPortal
๐ง Approach
- Use
childrenfor 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
WizardStep
๐ง 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
childrenfor 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.memochange this? - What are its limitations?
โ Strong Answer
- By default, React re-renders when parent renders
React.memodoes 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
- Stable reference (
โ 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
โ 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
useEffectruns 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
19. How would you audit a large app for prop-related performance issues?
๐ 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