π Smart vs Dumb Components (Container vs Presentational) β Complete Theory Guide
1. Introduction
πΉ What are Smart vs Dumb Components?
This pattern divides React components into two categories:π§ Smart Components (Container Components)
- Responsible for logic, state, and data fetching
- Handle side effects (API calls, subscriptions)
- Pass data down to child components
π¨ Dumb Components (Presentational Components)
- Focus only on UI rendering
- Receive data via props
- No business logic (or minimal UI logic)
πΉ Why is it Important in React?
- Improves separation of concerns
- Enhances reusability
- Makes components easier to:
- Test
- Maintain
- Scale
πΉ When & Why We Use It
Use this pattern when:- Components become too complex
- UI needs to be reused across different data sources
- You want clean architecture separation
- Working with:
- API-heavy apps
- Complex state management (Redux, Context)
2. Concepts / Internal Workings
πΉ 2.1 Separation of Concerns
- Smart components β βHow things workβ
- Dumb components β βHow things lookβ
πΉ 2.2 Data Flow (Unidirectional)
- Data flows downward
- Events bubble upward via callbacks
πΉ 2.3 How It Works Internally in React
React does NOT differentiate between smart/dumb:- All components become fiber nodes
- Differences are architectural, not technical
- Smart component triggers state updates
- React schedules reconciliation
- Dumb components re-render based on props
πΉ 2.4 Relationship with Other React Features
β Hooks
- Smart components heavily use:
useStateuseEffectuseReducer
β Context API
- Can replace smart components for global state
β Redux / Zustand
- Often replaces container logic entirely
- Dumb components become pure UI layers
β Composition
πΉ 2.5 Evolution of the Pattern
Originally:- Class components + HOCs
- Hooks reduce need for explicit containers
3. Syntax & Examples
πΉ 3.1 Basic Container + Presentational
πΉ 3.2 With Event Handling
πΉ 3.3 Using Custom Hooks Instead of Containers
πΉ 3.4 Composition-Based Container
πΉ 3.5 Multiple Presentational Components
πΉ 3.6 Controlled vs Uncontrolled Hybrid
4. Edge Cases / Common Mistakes
β οΈ 4.1 Over-Separating Components
β οΈ 4.2 Dumb Components Containing Logic
β οΈ 4.3 Prop Drilling Explosion
β οΈ 4.4 Tight Coupling Between Components
β οΈ 4.5 Unnecessary Containers with Hooks
β οΈ 4.6 Re-render Issues
- Passing new functions/objects
- Causes unnecessary updates in dumb components
5. Best Practices
β 5.1 Prefer Hooks Over Containers (Modern React)
- Replace containers with custom hooks where possible
β 5.2 Keep Presentational Components Pure
β 5.3 Co-locate Logic When Appropriate
- Donβt over-abstract prematurely
β 5.4 Use Context for Shared State
Avoid prop drilling in deeply nested treesβ 5.5 Optimize Rendering
React.memofor dumb componentsuseCallbackfor handlersuseMemofor derived data
β 5.6 Design Clean APIs
Bad:β 5.7 Balance Flexibility vs Simplicity
- Too many containers β hard to debug
- Too few β messy logic
β 5.8 Think in Terms of Responsibilities
Ask:- Does this component manage data? β Smart
- Does it just render UI? β Dumb
π Summary
Smart vs Dumb components is a design pattern, not a React feature:- Smart β logic, state, orchestration
- Dumb β UI, rendering
- Hooks for logic
- Composition for structure
- Context for shared state
π Advanced Conceptual Questions β Smart vs Dumb Components (Container vs Presentational)
These are senior-level questions designed to test architecture thinking, trade-offs, and deep React understanding.1. Why is the Smart vs Dumb component pattern considered an architectural guideline rather than a strict rule?
β Strong Answer
React does not enforce this separation β itβs purely a design abstraction.- Internally, React treats all components the same:
- Functions β React elements β Fiber nodes
- The distinction exists to:
- Improve separation of concerns
- Make systems scalable
- Hooks allow logic to live anywhere
- Small apps donβt need strict separation
π‘ Why it matters
Over-applying it leads to:- Unnecessary indirection
- Boilerplate-heavy code
π Alternative
- Hooks-based architecture replaces containers:
2. How does this pattern influence Reactβs rendering behavior and performance?
β Strong Answer
It impacts performance via prop-driven re-renders.- Smart component updates β passes new props β dumb component re-renders
π‘ Key Insight
Dumb components are ideal candidates for:π Trade-off
3. When does this pattern break down in modern React applications?
β Strong Answer
It breaks down when:- Hooks replace containers
- Logic becomes too fragmented
- Over-abstraction increases complexity
Example Problem
π‘ Insight
Modern React favors:- Colocation of logic + UI
- Separation only when necessary
4. How do you decide whether a component should be smart or dumb?
β Strong Answer
Ask:- Does it manage state or side effects? β Smart
- Is it reusable UI? β Dumb
Real-world heuristic
π‘ Key Insight
Components can be hybrid β strict separation is not always optimal.5. What are the risks of making presentational components βtoo dumbβ?
β Strong Answer
Over-dumb components:- Become overly dependent on props
- Lead to prop explosion
π‘ Why this is bad
- Hard to maintain API
- Reduced readability
π Alternative
Encapsulate minor logic inside UI when appropriate.6. How does this pattern interact with Context API?
β Strong Answer
Context can replace smart components for shared state.π‘ Trade-offs
β οΈ Pitfall
Context updates β all consumers re-render7. How would you refactor a legacy container-heavy codebase using hooks?
β Strong Answer
- Extract logic into custom hooks:
- Replace containers:
π‘ Benefit
- Fewer layers
- Better readability
- Easier testing
8. What is a subtle bug caused by mixing smart and dumb responsibilities?
β Strong Answer
Example:π‘ Why itβs problematic
- Harder to reuse
- Conflicts with external state control
π Fix
Lift state or convert to controlled component.9. How does this pattern affect testability?
β Strong Answer
Dumb components:- Easy to test
- Pure β deterministic
- Require mocking APIs
Example
π‘ Insight
Separating concerns β better unit tests10. When would you intentionally violate this pattern?
β Strong Answer
- Small components
- Performance-sensitive areas
- Co-located logic improves clarity
Example
11. How does prop drilling relate to this pattern?
β Strong Answer
Containers passing props down multiple layers:π‘ Problem
- Tight coupling
- Maintenance difficulty
π Solution
- Context
- Composition
12. How do you design APIs to avoid prop explosion in dumb components?
β Strong Answer
Group props:π‘ Insight
Better API β easier scaling13. What performance issues arise from poorly designed containers?
β Strong Answer
- Frequent re-renders
- Passing unstable props
π‘ Fix
useCallbackuseMemoReact.memo
14. How do smart components impact bundle splitting and lazy loading?
β Strong Answer
Smart components often:- Contain heavy logic
- Are good candidates for lazy loading
π‘ Insight
Split at container level, not UI level15. How does this pattern evolve in server components (React 18+)?
β Strong Answer
- Server components act like smart components
- Fetch data on server
- Pass props to client (dumb components)
π‘ Insight
Pattern still exists, but shifted across server/client boundary16. What is the difference between βsmart componentβ and βstateful componentβ?
β Strong Answer
- Stateful β Smart necessarily
π‘ Insight
Smart = business logic + orchestration Stateful = just local state17. How do you handle shared logic across multiple containers?
β Strong Answer
Extract into custom hooks:π‘ Why
- Avoid duplication
- Maintain consistency
18. What is the biggest misconception about this pattern?
β Strong Answer
That it must be strictly followed everywhereπ‘ Reality
- Itβs a guideline
- Modern React favors:
- Hooks
- Composition
- Context
π Final Takeaway
A senior-level understanding means:- Knowing when to apply the pattern
- Knowing when to break it
- Designing for:
- Clarity
- Performance
- Scalability
π Advanced MCQs β Smart vs Dumb Components (Container vs Presentational)
These questions test real-world reasoning, trade-offs, and subtle React behavior.1. What is the primary architectural risk of overusing container components?
Options:
A. Increased bundle size due to more files B. Tight coupling between UI and business logic C. Excessive component nesting and indirection D. React cannot optimize deeply nested containersβ Correct Answer: C
β Explanation:
Overusing containers leads to:- Indirection
- Debugging complexity
- Cognitive load
β Why others are wrong:
- A: File count doesnβt directly impact bundle size
- B: Containers actually reduce coupling
- D: React handles deep trees fine
2. What subtle performance issue exists here?
Options:
A. UI wonβt re-render B. UI re-renders unnecessarily C. React throws warning D. Config object is immutableβ Correct Answer: B
β Explanation:
New object created on every render β breaks memoization.β Why others are wrong:
- A: Opposite β it does re-render
- C: No warning
- D: Incorrect assumption
3. When migrating to hooks, what is the biggest shift in this pattern?
Options:
A. Dumb components disappear B. Containers become unnecessary in many cases C. Hooks replace presentational components D. Composition is no longer neededβ Correct Answer: B
β Explanation:
Hooks allow logic reuse without extra container layers.β Why others are wrong:
- A: UI components still exist
- C: Hooks donβt replace UI
- D: Composition is still core
4. What is the main issue in this βdumbβ component?
Options:
A. Syntax error B. Violates React rules C. Breaks strict presentational pattern D. Causes performance issueβ Correct Answer: C
β Explanation:
This introduces internal logic β no longer purely presentational.β Why others are wrong:
- A: Valid syntax
- B: No rule violation
- D: Not necessarily
5. What is the biggest drawback of making components βtoo dumbβ?
Options:
A. React cannot optimize them B. They require more hooks C. Prop explosion and poor API design D. They cannot be reusedβ Correct Answer: C
β Explanation:
Too many props:β Why others are wrong:
- A: React can optimize fine
- B: Hooks not required
- D: They are reusable
6. What happens when a container passes unstable callbacks?
Options:
A. UI will not render B. UI re-renders every time C. React throws error D. Callback is memoized automaticallyβ Correct Answer: B
β Explanation:
New function each render β breaksReact.memo
β Why others are wrong:
- A: It renders
- C: No error
- D: React does not auto-memoize
7. What is the key trade-off between context and container components?
Options:
A. Context is always faster B. Containers cannot share state C. Context introduces implicit dependencies D. Containers cannot scaleβ Correct Answer: C
β Explanation:
Context hides data flow β harder to trace/debug.β Why others are wrong:
- A: Not always faster
- B: Containers can share via props
- D: Containers scale fine
8. What subtle bug can arise here?
Options:
A. Renders empty B. Throws runtime error C. Logs warning only D. React skips renderingβ Correct Answer: B
β Explanation:
Accessingdata.value when data is undefined β crash.
β Why others are wrong:
- A: Would require optional chaining
- C: No warning
- D: React doesnβt skip
9. Why is this pattern problematic?
Options:
A. Too many props B. UI becomes tightly coupled to business logic C. fetchData is invalid prop D. Causes re-renderβ Correct Answer: B
β Explanation:
UI now knows about data fetching β breaks separation.β Why others are wrong:
- A: Not necessarily
- C: Valid prop
- D: Not guaranteed
10. What is the issue with this container?
Options:
A. Invalid React pattern B. Unnecessary abstraction C. Causes memory leak D. Breaks compositionβ Correct Answer: B
β Explanation:
Container adds no value β redundant layer.β Why others are wrong:
- A: Valid
- C: No leak
- D: Composition still works
11. What happens when context updates frequently in a smart component replacement?
Options:
A. Only smart components re-render B. All consumers re-render C. Only changed props update D. React batches automaticallyβ Correct Answer: B
β Explanation:
Context triggers re-render of all consumers.β Why others are wrong:
- A: Incorrect
- C: Not how context works
- D: Batching doesnβt prevent re-renders
12. What is the benefit of using React.memo on dumb components?
Options:
A. Prevents mounting B. Skips re-render if props are unchanged C. Caches component output forever D. Removes need for stateβ Correct Answer: B
β Explanation:
Shallow prop comparison prevents unnecessary renders.β Why others are wrong:
- A: Still mounts
- C: Not permanent cache
- D: State still exists
13. What design flaw is present here?
Options:
A. JSX invalid B. UI is no longer reusable C. Too much nesting without clear responsibility D. React throws warningβ Correct Answer: C
β Explanation:
Unclear separation β poor architecture.β Why others are wrong:
- A: Valid JSX
- B: Not necessarily
- D: No warning
14. When is it acceptable for a βdumbβ component to have state?
Options:
A. Never B. When managing UI-only state (e.g., hover, input) C. Only in class components D. Only in containersβ Correct Answer: B
β Explanation:
UI-related state is acceptable:β Why others are wrong:
- A: Too strict
- C: Irrelevant
- D: Incorrect
15. What is the biggest debugging challenge with context replacing containers?
Options:
A. Context cannot be logged B. Implicit data flow makes tracing harder C. Context causes syntax errors D. Components cannot access contextβ Correct Answer: B
β Explanation:
Data source is hidden β harder to trace bugs.β Why others are wrong:
- A: Can log
- C: No syntax issue
- D: They can access
16. What is the main reason to colocate logic instead of using containers?
Options:
A. Reduces bundle size B. Improves readability and reduces indirection C. Required by React D. Avoids hooksβ Correct Answer: B
β Explanation:
Fewer layers β easier to understand.β Why others are wrong:
- A: Not main reason
- C: Not required
- D: Hooks still used
17. What subtle issue occurs with this pattern?
Options:
A. UI cannot access data B. Data always stable C. UI re-renders whenever container updates D. React skips updatesβ Correct Answer: C
β Explanation:
Any container update β UI re-render.β Why others are wrong:
- A: It can
- B: Not guaranteed
- D: Incorrect
π Final Insight
These MCQs test whether you truly understand:- The trade-offs, not just definitions
- How React behavior (re-renders, props, context) affects architecture
- When to apply or avoid the pattern
π Smart vs Dumb Components β Advanced Coding Problems (Production-Level)
These problems simulate real-world frontend architecture challenges where you must decide separation of concerns, not just write code.π§© 1. Search Page with Debounced API (Container Separation)
π§ Problem
Build a search page:- Input field
- Results list
βοΈ Constraints
- Debounce API calls (300ms)
- Show loading + error states
- Cancel previous requests
β Expected Behavior
- Typing triggers API after delay
- Results update dynamically
- No duplicate calls
β οΈ Edge Cases
- Rapid typing
- Empty input
- API failure
π‘ Solution Approach
- Smart component:
- Handles debouncing (
useEffect) - Fetch logic + state
- Handles debouncing (
- Dumb component renders UI only.
π§© 2. Paginated Table with Sorting
π§ Problem
Build a table:- Pagination
- Sorting
- Server-side data
βοΈ Constraints
- Sorting triggers API
- Pagination state preserved
β οΈ Edge Cases
- Changing sort resets page
- Empty results
π‘ Solution
- Smart: manages
page,sort, API - Dumb: renders table + controls
π§© 3. Form with Validation + Submission
π§ Problem
Split form logic from UI.βοΈ Constraints
- Sync + async validation
- Disable submit when invalid
π‘ Approach
- Smart: validation + state
- Dumb: input rendering
π§© 4. Infinite Scroll Feed
π§ Problem
Load data as user scrolls.β οΈ Edge Cases
- Duplicate fetches
- Scroll jump
π‘ Solution
- Smart: IntersectionObserver + fetch
- Dumb: list rendering
π§© 5. Modal with Business Logic
π§ Problem
Modal:- Opens on action
- Submits form inside
βοΈ Constraints
- Controlled + uncontrolled mode
π‘ Solution
- Smart: open/close + submit
- Dumb: modal UI
π§© 6. Dashboard with Multiple Widgets
π§ Problem
Each widget:- Fetches its own data
- Reusable UI
π‘ Solution
- Shared hook for logic
- Dumb widget UI
π§© 7. Authentication Flow
π§ Problem
Login form:- API call
- Redirect on success
β οΈ Edge Cases
- Token expiration
- Error handling
π‘ Solution
- Smart: auth logic
- Dumb: form UI
π§© 8. Reusable Button System
π§ Problem
Create a button:- Supports loading, disabled, variants
β οΈ Edge Cases
- Double click
- Disabled state
π‘ Solution
- Dumb component handles UI
- Smart wrapper manages state if needed
π§© 9. File Upload Component
π§ Problem
Upload files with progress.βοΈ Constraints
- Show progress bar
- Retry on failure
π‘ Solution
- Smart: upload logic
- Dumb: progress UI
π§© 10. Feature Flag UI
π§ Problem
Show/hide features dynamically.π‘ Solution
- Smart: fetch flags
- Dumb: render conditionally
π§© 11. Notification System
π§ Problem
Global notifications.β οΈ Edge Cases
- Duplicate notifications
- Auto-dismiss
π‘ Solution
- Smart: queue management
- Dumb: toast UI
π§© 12. Data Visualization Dashboard
π§ Problem
Charts with dynamic data.βοΈ Constraints
- Large dataset
- Real-time updates
π‘ Solution
- Smart: data transformation
- Dumb: chart rendering
π§© 13. Multi-Step Form Wizard
π§ Problem
Steps share state.β οΈ Edge Cases
- Back navigation
- Partial completion
π‘ Solution
- Smart: step state
- Dumb: step UI
π§© 14. Drag-and-Drop List
π§ Problem
Reorder items.β οΈ Edge Cases
- Large lists
- Nested items
π‘ Solution
- Smart: drag logic
- Dumb: list UI
π§© 15. Live Chat Interface
π§ Problem
Real-time messaging.β οΈ Edge Cases
- Reconnection
- Message ordering
π‘ Solution
- Smart: WebSocket logic
- Dumb: chat UI
π§© 16. Theme Switcher
π§ Problem
Toggle themes globally.π‘ Solution
- Smart: context provider
- Dumb: UI toggle
π§© 17. Autosave Editor
π§ Problem
Auto-save user input.β οΈ Edge Cases
- Rapid typing
- Save conflicts
π‘ Solution
- Smart: debounce + API
- Dumb: editor UI
π§© 18. Role-Based Dashboard
π§ Problem
Render UI based on user roles.β οΈ Edge Cases
- Role change
- Unauthorized access
π‘ Solution
- Smart: role logic
- Dumb: UI
π§© 19. Image Gallery with Lazy Loading
π§ Problem
Load images on scroll.β οΈ Edge Cases
- Broken images
- Slow networks
π‘ Solution
- Smart: loading logic
- Dumb: grid UI
π§© 20. Analytics Event Tracker
π§ Problem
Track user interactions across UI.β οΈ Edge Cases
- Duplicate tracking
- Performance impact
π‘ Solution
- Smart: tracking logic
- Dumb: wrapped UI
π Final Takeaway
These problems test your ability to:- Decide where logic belongs
- Balance:
- Reusability
- Performance
- Readability
- Apply pattern practically, not dogmatically
π Smart vs Dumb Components β Real-World Debugging Challenges (Code Review Level)
These are production-grade bugs involving misuse of container/presentational patterns, React behavior quirks, and performance pitfalls.π 1. Unnecessary Re-renders from Container
β Buggy Code
π Whatβs Wrong
UI re-renders every time even if wrapped in React.memo.
π₯ Why It Happens
Inline function creates a new reference each render β breaks memoization.β Fix
β Best Practice
Stabilize callbacks passed from containers.π 2. Presentational Component Mutating Data
β Buggy Code
π Whatβs Wrong
Mutates props inside dumb component.π₯ Why It Happens
JS arrays are mutable β breaks React assumptions.β Fix
β Best Practice
Dumb components must be pure and immutable.π 3. Container Passing Unstable Objects
β Buggy Code
π Whatβs Wrong
UI re-renders unnecessarily.π₯ Why It Happens
New object every render β shallow compare fails.β Fix
β Best Practice
Memoize objects passed as props.π 4. Dumb Component Contains Side Effects
β Buggy Code
π Whatβs Wrong
Presentational component handles fetching.π₯ Why It Happens
Violates separation β harder to reuse/test.β Fix
Move logic to container:β Best Practice
Keep side effects in smart components or hooks.π 5. Prop Drilling Explosion
β Buggy Code
π Whatβs Wrong
Deep prop drilling.π₯ Why It Happens
Container pattern overused without context.β Fix
β Best Practice
Use context for deeply shared data.π 6. Controlled vs Uncontrolled Conflict
β Buggy Code
π Whatβs Wrong
Mixed controlled/uncontrolled behavior.π₯ Why It Happens
React expects one source of truth.β Fix
β Best Practice
Never mix controlled and uncontrolled state.π 7. UI Crashes on Missing Data
β Buggy Code
π Whatβs Wrong
Crashes ifuser is null.
π₯ Why It Happens
Assumes container always provides data.β Fix
β Best Practice
Dumb components should handle safe rendering.π 8. Container Re-fetch Loop
β Buggy Code
π Whatβs Wrong
Infinite loop.π₯ Why It Happens
fetchData recreated every render.
β Fix
β Best Practice
Stabilize dependencies in smart components.π 9. Dumb Component Re-rendering Too Often
β Buggy Code
π Whatβs Wrong
Always re-renders.π₯ Why It Happens
New array reference.β Fix
Memoize items in container.β Best Practice
Stabilize arrays passed to UI.π 10. Incorrect Responsibility Split
β Buggy Code
π Whatβs Wrong
UI triggers data fetching.π₯ Why It Happens
Responsibility inverted.β Fix
Move effect to container.β Best Practice
Containers control lifecycle effects.π 11. Hidden Coupling via Props
β Buggy Code
π Whatβs Wrong
UI tied to specific API logic.π₯ Why It Happens
Breaks abstraction.β Fix
Pass data, not behavior.β Best Practice
Keep UI generic.π 12. State Reset on Re-mount
β Buggy Code
π Whatβs Wrong
UI state resets when toggled.π₯ Why It Happens
Component unmounts/remounts.β Fix
Keep mounted or lift state.β Best Practice
Understand lifecycle with conditional rendering.π 13. Over-Abstracted Container
β Buggy Code
π Whatβs Wrong
No logic β useless abstraction.π₯ Why It Happens
Overuse of pattern.β Fix
Remove container.β Best Practice
Only abstract when needed.π 14. Multiple Sources of Truth
β Buggy Code
π Whatβs Wrong
Two states for same data.π₯ Why It Happens
State duplication.β Fix
Use single source of truth.β Best Practice
Lift state or fully control component.π 15. Context Overuse Re-rendering UI
β Buggy Code
π Whatβs Wrong
All consumers re-render.π₯ Why It Happens
New object each render.β Fix
β Best Practice
Memoize context values.π 16. Incorrect Memo Usage
β Buggy Code
π Whatβs Wrong
Memo ineffective.π₯ Why It Happens
New object reference.β Fix
Memoizedata.
β Best Practice
Memo only works with stable props.π 17. Event Handler Overwrites
β Buggy Code
π Whatβs Wrong
Container handler ignored.π₯ Why It Happens
UI overrides handler.β Fix
Merge handlers.β Best Practice
Compose event handlers, donβt override.π 18. Async Race Condition
β Buggy Code
π Whatβs Wrong
Outdated results overwrite new ones.π₯ Why It Happens
No request cancellation.β Fix
Use AbortController or track latest request.β Best Practice
Handle async race conditions in containers.π Final Takeaway
Real-world bugs come from:- β Blurred responsibilities
- β Unstable props
- β Hidden coupling
- β Misunderstanding React re-rendering
- Clear separation
- Predictable data flow
- Performance-aware design
π Smart vs Dumb Components β Real-World Machine Coding Problems (Senior Architect Level)
These problems simulate production-grade frontend systems where you must design clear separation between container (logic) and presentational (UI) while handling scale, performance, and edge cases.π§© 1. Global Search with Suggestions (Debounced + Cancelable)
π§ Problem
Build a search bar with:- Live suggestions dropdown
- Debounced API calls
- Keyboard navigation
π― UI Behavior
- Typing shows suggestions
- β β navigate results
- Enter selects
π Data Flow
- Container:
- query state
- debounced API
- active index
- Dumb:
- input + list rendering
β οΈ Edge Cases
- Rapid typing β cancel previous requests
- Empty input
- No results
β‘ Performance
- Debounce + request cancellation
- Memoize suggestion list
π Architecture
π Approach
- Manage query + debounce in container
- Use
AbortControllerfor cancellation - Pass results to UI
π§© 2. Real-Time Chat System (WebSocket + UI Separation)
π§ Problem
Build chat:- Live messages
- Input box
- Typing indicator
π― UI Behavior
- Messages update in real-time
- Scroll to latest message
π Data Flow
- Container:
- WebSocket connection
- message state
- Dumb:
- chat list + input UI
β οΈ Edge Cases
- Reconnection
- Message ordering
β‘ Performance
- Virtualized list for messages
π Architecture
π Approach
- Connect socket in container
- Maintain message queue
- Render via UI
π§© 3. Complex Form Builder (Dynamic Fields + Validation)
π§ Problem
Dynamic form:- Add/remove fields
- Validation rules
- Async validation
π Data Flow
- Container:
- form state
- validation logic
- Dumb:
- input components
β οΈ Edge Cases
- Nested fields
- Async validation race
β‘ Performance
- Field-level updates
π Architecture
π Approach
- Store form schema
- Validate on change
- Pass props to inputs
π§© 4. Analytics Dashboard (Multiple Data Sources)
π§ Problem
Dashboard:- Multiple widgets
- Independent data fetching
π Data Flow
- Container per widget OR shared hook
β οΈ Edge Cases
- Partial failures
- Loading states
β‘ Performance
- Parallel API calls
- Memoized charts
π Architecture
- Smart widgets + dumb chart components
π Approach
- Fetch per widget
- Normalize data
- Render UI
π§© 5. File Upload System with Retry & Progress
π§ Problem
Upload files:- Progress bar
- Retry failed uploads
π Data Flow
- Container:
- upload logic
- progress tracking
- Dumb:
- file list UI
β οΈ Edge Cases
- Network failure
- Large files
β‘ Performance
- Chunk uploads
π Approach
- Track upload state
- Retry failed chunks
- Update UI
π§© 6. Role-Based Access UI
π§ Problem
Render UI based on roles/permissions.π Data Flow
- Container:
- role logic
- Dumb:
- UI rendering
β οΈ Edge Cases
- Async role fetch
- Role change mid-session
π Approach
- Store roles in context
- Conditionally render UI
π§© 7. Infinite Scroll Feed with Deduplication
π§ Problem
Load content on scroll.β οΈ Edge Cases
- Duplicate items
- Scroll jitter
β‘ Performance
- Virtualization
π Approach
- Track page
- Deduplicate results
- Append data
π§© 8. Theme System (Global + Local Overrides)
π§ Problem
Support:- Global theme
- Component-level override
π Data Flow
- Container:
- theme state (context)
- Dumb:
- UI components
β οΈ Edge Cases
- Nested overrides
π Approach
- Context provider
- Merge themes
π§© 9. Notification Queue System
π§ Problem
Toast notifications:- Stack
- Auto-dismiss
- Priority handling
β οΈ Edge Cases
- Rapid fire notifications
- Duplicate suppression
β‘ Performance
- Avoid re-rendering all toasts
π Approach
- Queue in container
- Render list in UI
π§© 10. Autosave Rich Text Editor
π§ Problem
Editor with:- Auto-save
- Conflict handling
β οΈ Edge Cases
- Fast typing
- Save conflicts
β‘ Performance
- Debounced saves
π Approach
- Track content changes
- Debounce save
- Handle conflicts
π§© 11. Drag-and-Drop Kanban Board
π§ Problem
Reorder cards across columns.β οΈ Edge Cases
- Nested drag
- Performance on large boards
β‘ Performance
- Avoid full re-render
π Approach
- Maintain board state
- Update on drag
π§© 12. Command Palette (Keyboard Driven UI)
π§ Problem
Global command system.β οΈ Edge Cases
- Keyboard conflicts
- Search ranking
π Approach
- Container handles logic
- UI renders filtered results
π§© 13. Virtualized Data Table
π§ Problem
Large dataset table:- Sorting
- Filtering
β‘ Performance
- Windowing
- Memoization
π Approach
- Compute visible rows
- Render subset
π§© 14. Multi-Step Checkout Flow
π§ Problem
Checkout:- Multiple steps
- Shared state
β οΈ Edge Cases
- Back navigation
- Partial data
π Approach
- Container stores state
- UI renders steps
π§© 15. Live Stock Ticker
π§ Problem
Real-time price updates.β οΈ Edge Cases
- Rapid updates
- Out-of-order data
β‘ Performance
- Batch updates
π Approach
- WebSocket container
- UI renders prices
π§© 16. Feature Flag System (A/B Testing)
π§ Problem
Toggle features dynamically.β οΈ Edge Cases
- Async flags
- Experiment tracking
π Approach
- Fetch flags
- Provide via context
π§© 17. Global Error Handling System
π§ Problem
Catch errors and show fallback UI.β οΈ Edge Cases
- Nested errors
- Reset behavior
π Approach
- Error boundary (smart)
- UI fallback (dumb)
π§© 18. Media Gallery with Lazy Loading
π§ Problem
Image/video gallery:- Lazy load
- Preview modal
β οΈ Edge Cases
- Broken media
- Slow network
β‘ Performance
- IntersectionObserver
π Approach
- Container handles loading
- UI renders grid
π§© 19. Activity Timeline with Grouping
π§ Problem
Group events by date/time.β οΈ Edge Cases
- Timezone issues
- Real-time updates
π Approach
- Transform data in container
- UI renders grouped list
π§© 20. Global Keyboard Shortcut Manager
π§ Problem
Handle shortcuts across app.β οΈ Edge Cases
- Conflicts
- Focus issues
π Approach
- Container listens to key events
- UI triggers actions
π Final Takeaway
These problems test:- Designing clean separation of concerns
- Deciding:
- What belongs in container vs UI
- Handling:
- Performance
- Edge cases
- Real-world complexity
π FAANG-Level Interview Questions β Smart vs Dumb Components (Container vs Presentational)
These questions evaluate architecture decisions, performance awareness, and real-world trade-offs, not just definitions.1. How would you design a scalable component architecture for a large dashboard using smart/dumb separation?
π Follow-ups
- Would you use one global container or multiple?
- How do you prevent tight coupling?
β Strong Answer
- Split into feature-level containers (per widget/module)
- Keep UI components reusable and stateless
- Use shared hooks for cross-cutting logic
π‘ Why
- Avoids monolithic container
- Enables independent scaling
β Weak Answer
βOne container at the top handles everythingβ π Fails due to:- Tight coupling
- Poor scalability
- Difficult debugging
2. When would you intentionally NOT separate smart and dumb components?
π Follow-ups
- How does this impact performance and readability?
β Strong Answer
- Small components
- UI-specific logic (hover, toggle)
- When separation introduces unnecessary abstraction
π‘ Insight
Colocation improves readability when complexity is low.β Weak Answer
βAlways separate for best practiceβ π Shows rigid thinking, not practical engineering3. How does this pattern impact re-render behavior in React?
π Follow-ups
- How do you optimize re-renders in dumb components?
β Strong Answer
- Containers update β pass new props β UI re-renders
- Optimize via:
React.memo- Stable props (
useMemo,useCallback)
β Weak Answer
βDumb components donβt re-renderβ π Incorrect β they re-render when props change4. You notice a presentational component re-rendering frequently. How do you debug?
π Follow-ups
- What tools and techniques?
β Strong Answer
- Use React DevTools (highlight updates)
- Check prop identity
- Inspect parent container updates
- Add memoization selectively
β Weak Answer
βWrap everything in memoβ π Blind optimization without diagnosis5. Compare using context vs container components for state management.
π Follow-ups
- When does context become problematic?
β Strong Answer
π Context causes global re-renders if misused.
β Weak Answer
βContext is always betterβ π Ignores performance and debugging trade-offs6. How would you refactor a container-heavy legacy codebase using hooks?
π Follow-ups
- What risks exist during migration?
β Strong Answer
- Extract logic into custom hooks
- Replace containers gradually
- Maintain backward compatibility
β Weak Answer
βRemove all containers immediatelyβ π Risky, breaks system stability7. What are the risks of passing functions from containers to dumb components?
π Follow-ups
- How do you mitigate them?
β Strong Answer
- Causes re-renders due to new references
- Breaks memoization
β Weak Answer
βNo risksβ π Ignores performance implications8. How do you prevent prop explosion in presentational components?
π Follow-ups
- Alternative API designs?
β Strong Answer
- Use:
- Object props
- Composition
- Slot-based APIs
β Weak Answer
βJust pass more propsβ π Leads to poor API design9. How does this pattern interact with server components (React 18+)?
π Follow-ups
- Where should data fetching happen?
β Strong Answer
- Server components act like smart components
- Client components act like presentational
β Weak Answer
βNo change with server componentsβ π Shows outdated understanding10. What is a subtle bug caused by duplicating state between container and UI?
π Follow-ups
- How do you fix it?
β Strong Answer
- Multiple sources of truth
- Lift state or make controlled
β Weak Answer
βSync them manuallyβ π Fragile and error-prone11. How do you design a reusable form system using this pattern?
π Follow-ups
- Where does validation logic live?
β Strong Answer
- Container:
- state + validation
- UI:
- input rendering
β Weak Answer
βPut everything inside input componentsβ π Poor separation12. What are the performance implications of using context instead of containers?
π Follow-ups
- How to optimize context?
β Strong Answer
- Context updates β all consumers re-render
- Optimize via:
- splitting contexts
- memoizing values
β Weak Answer
βContext avoids re-rendersβ π Incorrect13. How do you enforce boundaries between smart and dumb components?
π Follow-ups
- Tooling or patterns?
β Strong Answer
- TypeScript interfaces
- Folder structure (containers/ui)
- Code reviews
β Weak Answer
βDevelopers should rememberβ π Not enforceable14. What is the biggest debugging challenge in this pattern?
π Follow-ups
- How do you solve it?
β Strong Answer
- Tracing data flow across layers
- Especially with context/hooks
- DevTools
- Logging
- Clear boundaries
β Weak Answer
βCheck console logsβ π Too shallow15. How would you design a feature flag system using this pattern?
π Follow-ups
- How to avoid re-renders?
β Strong Answer
- Container/context provides flags
- UI consumes flags
β Weak Answer
βHardcode flags in UIβ π Not scalable16. What happens when a container re-renders frequently?
π Follow-ups
- How to isolate updates?
β Strong Answer
- All children re-render unless memoized
- Use:
React.memo- state splitting
β Weak Answer
βNo impactβ π Incorrect17. How do you handle async race conditions in smart components?
π Follow-ups
- Example?
β Strong Answer
- Use AbortController
- Track latest request
β Weak Answer
βJust await responseβ π Ignores race conditions18. When does this pattern hurt developer productivity?
π Follow-ups
- How to fix?
β Strong Answer
- Over-abstraction
- Too many layers
- Simplify architecture
- Co-locate logic when needed
β Weak Answer
βNever hurtsβ π Unrealistic19. How do you balance flexibility vs control in UI components?
π Follow-ups
- Example?
β Strong Answer
- Too flexible β misuse
- Too strict β limited reuse
- clear APIs
- constraints
β Weak Answer
βMake everything flexibleβ π Leads to chaos20. What distinguishes a senior engineerβs approach to this pattern?
π Follow-ups
- What signals maturity?
β Strong Answer
- Knows when to:
- apply it
- relax it
- Focuses on:
- maintainability
- performance
- clarity
β Weak Answer
βAlways follow best practices strictlyβ π Lacks real-world adaptabilityπ Final Insight
Senior-level mastery means:- Not just knowing the pattern
- But understanding:
- When to apply it
- When to break it
- How it affects performance and debugging