This guide covers:
- Conceptual questions
- Real-world architecture questions
- Performance & optimization
- State management
- Hooks & internals
- Security & testing
- System design thinking
Use this to crack real interviews, not just MCQs.
π§ React Internals & Core Concepts
β 1. How does React actually work internally?
Answer:
React creates a Virtual DOM, compares it with the previous tree using reconciliation, and updates only the changed parts of the real DOM using diffing. Rendering is triggered by state or prop changes.
β 2. What is reconciliation?
Answer:
Reconciliation is the process where React:
- Creates a new Virtual DOM
- Diffs it against the old one
- Updates the minimal set of DOM nodes
Keys help React optimize this process.
β 3. Virtual DOM vs Real DOM β is Virtual DOM faster?
Answer:
Not always.
Virtual DOM reduces unnecessary DOM updates, not DOM updates themselves. React batches updates and applies them efficiently.
βοΈ Hooks (Very Common)
β 4. Difference between useEffect and useLayoutEffect?
Answer:
useEffectruns after paint (non-blocking)useLayoutEffectruns before paint (blocking)
Use useLayoutEffect only when measuring layout.
β 5. When should you use useReducer instead of useState?
Answer:
Use useReducer when:
- State logic is complex
- Multiple related state transitions exist
- State updates depend on previous state
β 6. Why canβt hooks be used conditionally?
Answer:
Hooks rely on call order, not names. Conditional hooks break the call sequence, causing React to associate state incorrectly.
π§© Advanced Patterns
β 7. Explain Compound Components pattern.
Answer:
Compound components share state implicitly via Context. Parent manages state, children consume it β allowing flexible UI composition.
β 8. Render Props vs HOC vs Hooks?
Answer:
- HOC β Wrapper-based reuse
- Render Props β Function-based reuse
- Hooks β Logic reuse (preferred today)
Hooks replaced most use cases.
π§ State Management
β 9. Context API vs Redux β when to use which?
Answer:
- Context β Small, low-frequency updates (auth, theme)
- Redux β Large, complex, frequently changing global state
β 10. What is normalized state?
Answer:
Storing data by ID instead of nesting to:
- Avoid duplication
- Improve updates
- Improve performance
Common in Redux Toolkit.
β 11. Redux Toolkit advantages?
Answer:
- Less boilerplate
- Built-in immutability
- Async handling
- Better dev experience
π API & Data Fetching
β 12. React Query vs Redux?
Answer:
- Redux β Client state
- React Query β Server state
React Query handles caching, refetching, and synchronization automatically.
β 13. How do you handle API errors globally?
Answer:
- Central API layer
- Global error context
- Error boundaries for UI crashes
- Logging to monitoring tools
β‘ Performance Optimization
β 14. When should you use React.memo?
Answer:
When:
- Component is expensive
- Props donβt change often
Avoid premature memoization.
β 15. useCallback vs useMemo?
Answer:
useCallbackmemoizes functionsuseMemomemoizes values
Both prevent unnecessary re-renders.
β 16. How do you optimize large lists?
Answer:
- List virtualization
- Pagination
- Memoized rows
π‘οΈ Error Handling
β 17. What are Error Boundaries?
Answer:
Class components that catch rendering errors and display fallback UI instead of crashing the app.
β 18. Can error boundaries catch async errors?
Answer:
No. Async errors must be handled with try/catch.
π Authentication & Security
β 19. How do you handle authentication in React?
Answer:
- Central auth context
- JWT-based flow
- Protected routes
- Token persistence
β 20. Frontend RBAC β is it secure?
Answer:
No. Frontend RBAC is for UX only. Backend must enforce access control.
π§ͺ Testing
β 21. What should you test in React?
Answer:
Test:
- User behavior
- Interactions
- Error states
Avoid testing implementation details.
β 22. Component vs Integration testing?
Answer:
- Component β isolated UI behavior
- Integration β multiple components working together
π· TypeScript with React
β 23. Why use discriminated unions?
Answer:
To enforce valid prop combinations at compile time.
β 24. How do you type children properly?
Answer:
Use React.ReactNode.
ποΈ Architecture & System Design
β 25. How do you structure a large React app?
Answer:
Feature-based structure:
- Auth
- API
- Features
- Shared components
β 26. How do you avoid prop drilling?
Answer:
- Context API
- Compound components
- Custom hooks
β 27. SPA vs CSR vs SSR?
Answer:
- CSR β Client rendering
- SSR β Server rendering
- SPA β Single-page navigation
π― Scenario-Based Questions (Very Important)
β 28. App is slow β how do you debug?
Answer:
- React Profiler
- Memoization
- Reduce re-renders
- Optimize data fetching
β 29. Large form with dynamic fields β approach?
Answer:
Schema-driven form builder with reusable field components.
β 30. How do you design a dashboard?
Answer:
- API-driven data
- Loading & error states
- Caching
- Performance optimization
π¨ Common Interview Traps
β βRedux is always betterβ
β βVirtual DOM is always fasterβ
β βContext replaces Reduxβ
β βError boundaries catch all errorsβ
Avoid absolute statements.
π§ Final Rapid-Fire Questions
- Why keys are important?
- What causes unnecessary re-renders?
- When NOT to use memoization?
- Difference between controlled & uncontrolled inputs?
- How does React batching work?
π Final Advice for Interviews
β Explain why, not just how
β Use real examples
β Talk about trade-offs
β Show production experience
β Donβt over-engineer
π Conclusion
If you can confidently answer 70β80% of these questions, you are ready for:
- Senior React Developer
- Frontend Architect
- Tech Lead (Frontend)
This guide completes your Advanced React JS journey πβοΈπ