JS Guide
HomeQuestionsTopicsCompaniesResources
BookmarksSearch

Built for developers preparing for JavaScript, React & TypeScript interviews.

ResourcesQuestionsSupport
HomeQuestionsSearchProgress
HomeQuestionsreact

react

React components, hooks, patterns, and best practices

Explore 20 react topics to deepen your understanding

Your Progress

0 of 14 completed

0%

14 Questions

senior Level
1
Explain React.memo, useMemo, and useCallback. When should each be used?
senior
performance
React.memo prevents component re-renders when props are unchanged. useMemo caches computed values. useCallback caches function references. Use them only when you have measured performance issues - premature optimization adds complexity without benefit.
2
How does React's reconciliation algorithm work?
senior
internals
Reconciliation is React's diffing algorithm that compares the new virtual DOM tree with the previous one to determine minimal DOM updates. It uses heuristics: different element types trigger full subtree replacement, keys identify items in lists, and same-type elements update attributes.
3
What are React's concurrent features and how do Suspense and transitions work?
senior
concurrent
Concurrent React enables interruptible rendering, allowing React to pause low-priority work for urgent updates. Suspense handles async loading states declaratively. useTransition marks updates as non-urgent, and useDeferredValue defers expensive re-renders.
4
How do Error Boundaries work in React and what are their limitations?
senior
error-handling
Error Boundaries are class components that catch JavaScript errors in their child component tree, log them, and display fallback UI. They don't catch errors in event handlers, async code, SSR, or errors thrown in the boundary itself.
5
Explain common React patterns: Compound Components, Render Props, and Custom Hooks.
senior
patterns
Compound Components share implicit state between related components (like <select>/<option>). Render Props pass render functions to share code. Custom Hooks extract reusable stateful logic. Today, Custom Hooks are preferred over Render Props for most cases.
6
What are Higher-Order Components (HOCs) in React, and why are they less commonly used today?
senior
patterns
A Higher-Order Component is a function that takes a component and returns an enhanced component with additional props or behavior; they're less common now because React Hooks provide a cleaner solution for logic reuse without wrapper components.
7
What is Redux and Redux Thunk, and how do they manage application state and async operations?
senior
state-management
Redux is a predictable state container using a single store with pure reducer functions; Redux Thunk is middleware that enables async logic by allowing action creators to return functions that can dispatch actions and access state.
8
What security vulnerabilities should you address in React applications and how do you prevent them?
senior
security
Key vulnerabilities include XSS (mitigated by React's auto-escaping, but watch dangerouslySetInnerHTML and URL injection), CSRF (use tokens in API requests, SameSite cookies), and insecure storage (avoid localStorage for sensitive data, prefer httpOnly cookies).
9
How would you design and implement a reusable Pagination component in React?
senior
patterns
A reusable Pagination component manages page state, renders page numbers with ellipsis for large ranges, and exposes both controlled and uncontrolled APIs. It should include keyboard navigation, ARIA attributes for accessibility, and integrate cleanly with server-side pagination endpoints.
10
How does list virtualization (windowing) work in React and when should you use it?
senior
performance
List virtualization renders only the items currently visible in the viewport plus a small overscan buffer, replacing thousands of DOM nodes with a handful. This dramatically reduces initial render time, memory usage, and DOM size for large lists.
11
Explain React's hydration process and common hydration mismatch issues.
senior
rendering
Hydration is the process where React attaches event handlers and state to server-rendered HTML, making it interactive without re-rendering the DOM. Mismatches occur when server and client HTML differ, causing React to discard and re-render the affected subtree.
12
Explain React's diffing algorithm in detail. How does it achieve O(n) complexity?
senior
internals
React's diffing algorithm achieves O(n) complexity using two heuristics: elements of different types produce entirely different trees (tear down and rebuild), and elements of the same type are compared attribute-by-attribute. Keys enable efficient list reconciliation by matching children by identity rather than position.
13
Implement a basic version of useState from scratch.
senior
hooks
A simplified useState uses a module-level array to store state values and an index counter to track which state slot to use. The setter updates the stored value and triggers a re-render. The call-order dependency on the array index explains why hooks cannot be called conditionally.
14
Implement a basic version of useEffect from scratch.
senior
hooks
A simplified useEffect stores effect callbacks and their dependency arrays in a module-level array. After each render, it compares current dependencies against previous ones using shallow equality and runs the effect callback (plus its cleanup) only when dependencies have changed.