coding-interview-university
A complete computer science study plan to become a software engineer.
- 365k
- CC-BY-SA-4.0
- 2 wk ago
π£ React interview questions and answers to help you prepare for your next technical interview in 2026.
Repo Devinterview-io/react-interview-questions, read from GitHub 2 d ago. Devinterview-io has not joined Take My Repo.
Devinterview-io/react-interview-questions is a public repo on GitHub by Devinterview-io. π£ React interview questions and answers to help you prepare for your next technical interview in 2026. It declares no license on GitHub. Public does not mean open source: without a license, nobody is granted the right to reuse it. It has 284 stars and last changed on 2026-03-16. Nobody has reviewed it on Take My Repo yet, which says nothing about its quality. Read from GitHub on 2026-11-20.
In the maintainer's words. Shown from GitHub; Take My Repo does not keep a copy.
React is a declarative, component-based library for building user interfaces. As of 2026, it is governed by the React 19+ paradigm, emphasizing Concurrent Rendering, Server Components, and Actions.
While React still utilizes a Virtual DOM for reconciliation, the 2026 standard emphasizes Concurrent React. This allows React to prepare multiple versions of the UI simultaneously without blocking the main thread. By prioritizing updates (e.g., input typing over data fetching), React achieves better responsiveness. The diffing algorithm maintains $O(n)$ complexity through heuristic assumptions, optimized for modern browser engines.
Class Components are effectively legacy. Modern development exclusively uses Functional Components.
useState), side effects (useEffect), and memoization (useMemo, useCallback).use hook and automatic transitions has replaced much of the boilerplate previously required for data fetching.The architectural divide between Client Components and Server Components is fundamental. Server Components execute exclusively on the server, sending rendered UI to the client. This reduces bundle size significantly, as component-level logic and dependencies remain on the server, shipping zero-kilobyte JavaScript to the browser for static portions of the UI.
Data remains strictly one-way (parent-to-child). However, Server Actions have replaced the traditional pattern of fetching data via useEffect + useState. Actions allow you to call server-side functions directly from UI elements (e.g., forms), integrating mutation logic directly into the component lifecycle.
JSX remains the syntax extension for JavaScript. In modern build tools (e.g., Vite, Rspack), JSX is transformed into _jsx runtime calls, optimized for the specific rendering target (Client vs. Server).
The following snippet demonstrates the shift toward useActionState and modern functional patterns, replacing legacy class-based state management.
'use client'; // Required for interactivity in RSC environments
import { useActionState } from 'react';
// Modern approach: Server Actions integration
async function incrementCounter(previousState, formData) {
return previousState + 1;
}
export default function Counter() {
const [state, action, isPending] = useActionState(incrementCounter, 0);
return (
<form action={action}>
<button type="submit" disabled={isPending}>
Clicked {state} times
</button>
</form>
);
}
Audit Note: The Class-based component example in the original content is now considered an anti-pattern. New projects must utilize functional patterns to leverage Suspense and Streaming SSR capabilities inherent in the modern React pipeline.
Zone.js change detection). It mandates a strict Dependency Injection architecture.NgModules which previously burdened beginners.setState is effectively superseded by useActionState and useOptimistic hooks.@if, @for) has replaced *ngIf and *ngFor for better type safety and performance.<script setup> syntax are the industry best practice, offering the tightest integration between template logic and reactive state.A React component is the fundamental building block of modern React applications, encapsulating UI logic and structure. In the current ecosystem (React 19+), components are defined as function components. While class components remain technically supported for legacy compatibility, they are considered deprecated architectural patterns in favor of functional paradigms.
props as an argument and return UI elements. They leverage Hooks to manage state, context, and side effects.React.Component. These are now discouraged due to increased bundle sizes and complexities regarding this binding and lifecycle fragmentation.React.createElement transformation is largely optimized by modern compilers (like SWC or Babel), transpiling JSX directly into highly performant virtual DOM nodes.React applications maintain a hierarchical tree structure. The entry point (e.g., createRoot) initiates the tree, which propagates updates through Concurrent Rendering. This allows React to prioritize urgent updates (like user input) over transitionary background tasks, improving perceived performance.
React enforces unidirectional data flow. Data (props) flows strictly from parent to child.
useState or useReducer. In modern React, state updates trigger a re-render cycle where React computes the "diff" between the previous and current Virtual DOM, applying only necessary patches ($O(n)$ complexity).props drilling, utilizing useContext or external reactive stores (e.g., Zustand, TanStack Query) to facilitate cross-tree data access without performance bottlenecks.Lifecycle methods (componentDidMount, etc.) have been superseded by the useEffect hook and the broader Effect API.
<Suspense> boundaries. Rather than manually managing "mounting" status, components define their loading state declaratively, leading to a smoother user experience in data-intensive applications.Architectural Note: As of 2026, the focus has shifted from "lifecycle management" to "synchronization with external state," prioritizing Composition over the inheritance models used in older class-based designs.
Modern React development strictly prioritizes Functional Components using Hooks. While Class-based components remain supported for legacy compatibility, they are considered an anti-pattern in new feature development due to higher memory overhead and complex this binding behaviors.
Functional components leverage Hooks (e.g., useState, useEffect) to manage state and side effects, replacing the legacy lifecycle methods (componentDidMount, componentWillUnmount).
// React 19 no longer requires explicit 'import React' for JSX
const Greeting = ({ name }: { name: string }) => {
return <h1>Hello, {name}!</h1>;
};
export default Greeting;
Note: The use of TypeScript is the industry standard for 2026, providing static type checking for props and return types.
In 2026, the industry has transitioned away from manual lifecycle management toward declarative synchronization.
useTransition and useActionState, allow for non-blocking UI transitions and seamless form state management.Modern ecosystems rely on ESLint (Flat Config) and Biome or Prettier to enforce code quality.
| Feature | Legacy Status | 2026 Standard |
|---|---|---|
| Component Type | Class-based | Functional (Hooks) |
| Type Checking | PropTypes | TypeScript (Interface/Types) |
| Data Fetching | componentDidMount |
use API / TanStack Query |
| Rendering | Client-Side (CSR) | Server Components (RSC) / Streaming |
JSX (JavaScript XML) is a syntax extension for JavaScript that provides a declarative way to describe the UI structure. While it resembles HTML, it is a syntactic sugar for function calls that compile into the React element tree.
React.createElement (or the newer jsx() transform introduced in React 17+).{}. The React runtime handles the evaluation and injection of these expressions into the VDOM.React.createElement chains with readable, declarative trees.JSX (React 19 syntax):
// Direct usage of the new JSX transform
const element = <h1 className="title">Hello, World!</h1>;
Transpiled JavaScript (React 19 Runtime):
import { jsx as _jsx } from "react/jsx-runtime";
// The modern transform removes the need to import 'React' in every file
const element = _jsx("h1", { className: "title", children: "Hello, World!" });
The Virtual DOM (VDOM) remains a fundamental architectural pattern in React, though its implementation has evolved significantly with the introduction of React Fiber and concurrent rendering primitives. It serves as a declarative blueprint for the UI, allowing React to decouple UI state from expensive imperative browser DOM manipulations.
Initial Rendering: React creates a Fiber tree, a internal data structure representing the component tree. Each Fiber node corresponds to a React component or DOM element, holding state, props, and side effects.
Reconciliation (The Diffing Algorithm): When state updates occur, React triggers a re-render. It performs a tree comparison between the current Fiber tree and the new structure. React uses a heuristic $O(n)$ algorithm, assuming that components of the same type produce similar trees, to minimize computational overhead.
Fiber Architecture: Unlike older versions, the 2026 reconciliation process is incremental and interruptible. React can pause, abort, or reuse work on the component tree to prioritize urgent updates (e.g., user input) over background tasks (e.g., data fetching), maintaining high frame rates.
Batched Transitions: React 19+ utilizes useTransition and useDeferredValue to categorize updates. State changes are grouped into transitions, ensuring that lower-priority updates do not block the main thread, effectively decoupling logic from rendering.
Commit Phase: Once reconciliation is complete, React enters the "Commit Phase." Here, it applies changes to the actual DOM in a single pass. By batching these operations, React minimizes layout thrashing and forced synchronous reflows.
Concurrent Rendering: Modern React renders components "concurrently," meaning multiple versions of the UI can be prepared in memory simultaneously. The VDOM acts as a scratchpad where React experiments with changes before "committing" them to the screen, providing a seamless transition between states.
Declarative DOM Abstraction: Direct DOM manipulation (e.g., document.getElementById) is considered an anti-pattern. React provides useRef for necessary imperative escapes, but the VDOM ensures that the source of truth remains within the React component lifecycle, preventing synchronization desyncs.
Universal Reconciliation: The VDOM is platform-agnostic. While react-dom handles browser-specific updates, the reconciliation logic is reused by react-native (via native bridge) and react-three-fiber (via custom renderers), providing a consistent declarative API across platforms.
The efficiency of the VDOM is rooted in:
In 2026, Functional Components are the industry standard for all new development. Class Components are considered legacy and should be avoided in modern React 19+ applications.
Class Components (Legacy):
React.Component or React.PureComponent.this keyword, which often leads to complex binding issues.this.state.componentDidMount, componentDidUpdate).Functional Components (Modern):
this binding overhead.render() method returning JSX. Complex components often result in "wrapper hell" due to the limitations of inheritance and Higher-Order Components (HOCs).this.setState() triggers a shallow merge. useState and useReducer allow for granular state updates. In 2026, state is typically treated as immutable, often managed via deep-comparable structures or reactive primitives.useEffect hook enables synchronization logic. By focusing on state dependencies rather than lifecycle events, the code remains highly cohesive.useEffect is increasingly replaced by specialized hooks or server-side primitives in React 19+.static contextType (limited to one context) or Render Props.useContext hook allows multiple context consumptions. Compatible with modern state stores like Zustand, Valtio, or React Query, which leverage hooks for seamless reactivity.class hierarchies.this context.React handles events via SyntheticBaseEvent, a cross-browser wrapper around the native browser event. This abstraction ensures consistent interface behavior across environments (DOM, React Native) and provides performance optimizations.
React normalizes events so that they have the same properties across all browsers. As of React 19, synthetic events are not pooled, eliminating the need to call event.persist() to access event properties asynchronously.
camelCase for event handlers (e.g., onClick, onKeyDown) instead of the native HTML lowercase (e.g., onclick).In 2026, state is managed via useState. Binding in constructors is unnecessary, and the use of useCallback is recommended to prevent unnecessary re-renders of child components receiving event handlers.
import { useState, useCallback, FormEvent, ChangeEvent } from 'react';
export default function Form() {
const [value, setValue] = useState<string>('');
// useCallback optimizes performance by memoizing the handler reference
const handleChange = useCallback((e: ChangeEvent<HTMLInputElement>) => {
setValue(e.target.value);
}, []);
const handleSubmit = useCallback((e: FormEvent<HTMLFormElement>) => {
e.preventDefault();
console.log('Submitted:', value);
}, [value]);
return (
<form onSubmit={handleSubmit}>
<label htmlFor="name-input">Name:</label>
<input
id="name-input"
type="text"
value={value}
onChange={handleChange}
/>
<button type="submit">Submit</button>
</form>
);
}
ChangeEvent and FormEvent objects replace the generic event type, ensuring type safety in the event pipeline.useTransition should be used to prevent event handlers from blocking the main thread, maintaining a UI responsiveness complexity of $O(1)$ for input latency.In modern React (v19+), props and state remain the fundamental primitives for data propagation and UI synchronization. React's architecture follows a unidirectional data flow where data typically moves from parent to child via props, while state remains localized to the component or lifted to shared ancestors.
useState dispatch) schedules a re-render of the component tree to reflect the new state.shouldComponentUpdate (deprecated for functional components). Instead, we utilize useMemo, useCallback, and the memo Higher-Order Component to prevent unnecessary re-computations.use hook has modernized how we consume Promises and Context, allowing for cleaner asynchronous state resolution within components.useState. State is relegated to Client Components explicitly marked with the "use client" directive.'use client';
import React, { useState, memo } from 'react';
// Use memo to prevent unnecessary re-renders of stable children
const Button = memo(({ text, color, onClick }) => {
return (
<button style={{ backgroundColor: color }} onClick={onClick}>
{text}
</button>
);
});
const ColorPicker = () => {
const [color, setColor] = useState('blue');
// useCallback is omitted here for brevity,
// but recommended for complex prop-drilling scenarios.
return (
<div>
<p>Current Color: {color}</p>
<Button text="Red" color="red" onClick={() => setColor('red')} />
<Button text="Blue" color="blue" onClick={() => setColor('blue')} />
</div>
);
};
export default ColorPicker;
memo reduces the branching factor of the reconciliation process, effectively pruning sub-trees that do not require re-evaluation, optimizing performance towards $O(k)$ where $k$ is the number of changed nodes.Data propagation in React (v19+) adheres to the core principle of unidirectional data flow. While the fundamentals of Props and Callbacks remain, modern React emphasizes Server Components, Context API, and Signals (or state management libraries) to mitigate "prop drilling."
Props facilitate parent-to-child communication. In React 19, props are now treated as standard stable arguments to component functions, eliminating the need for React.FC wrapper types, which are now largely considered boilerplate.
Data moves up the tree when children invoke functions passed down as props. These functions typically trigger dispatch actions or state setters (e.g., useState, useActionState).
React.FC.interface or type for props, favoring discriminated unions for complex state transitions.children prop (or slot patterns) to compose components, reducing the need to pass data through multiple layers.In this 2026-compliant implementation, App maintains the state, and DropDown notifies the parent of changes via a callback, maintaining Single Source of Truth (SSOT).
// src/components/DropDown.tsx
interface DropDownProps {
options: string[];
onSelect: (option: string) => void;
selected: string;
}
// Modern function declaration without React.FC boilerplate
export function DropDown({ options, onSelect, selected }: DropDownProps) {
return (
<nav>
<p>Current: {selected}</p>
{options.map((opt) => (
<button
key={opt}
onClick={() => onSelect(opt)}
aria-pressed={selected === opt}
>
{opt}
</button>
))}
</nav>
);
}
// src/App.tsx
import { useState } from 'react';
import { DropDown } from './components/DropDown';
export default function App() {
const [selection, setSelection] = useState<string>('Apple');
const options = ['Apple', 'Banana', 'Cherry'];
return (
<main>
<DropDown
options={options}
onSelect={setSelection}
selected={selection}
/>
<section>You selected: {selection}</section>
</main>
);
}
For a tree of depth $d$ and branching factor $b$, passing props through every layer incurs:
Using Context API reduces maintenance complexity to $O(1)$ for leaf node access, effectively decoupling the intermediate nodes from the data propagation logic.
The original content relies on Class Components (React.Component), which are legacy patterns. In React 19, the industry standard for state management is the Hooks API. While class components remain supported for backward compatibility, they are deprecated in modern architectural paradigms.
Stateful components in React are components that manage internal data that persists across renders. In modern React, this is achieved using the useState or useReducer hooks. When state values update, React triggers a re-render of the component to synchronize the DOM with the new state.
In React 19, use the useState hook. This approach eliminates this binding issues and reduces boilerplate code.
import React, { useState } from 'react';
const ClickCounter = () => {
// useState returns the current value and a setter function
const [count, setCount] = useState(0);
const handleIncrement = () => {
// Functional updates ensure correct state transition based on previous value
setCount((prevCount) => prevCount + 1);
};
return (
<div>
<p>Count: {count}</p>
<button onClick={handleIncrement}>Increment</button>
</div>
);
};
export default ClickCounter;
React.memo or useMemo to prevent unnecessary re-renders of child components if props remain referentially equal, maintaining efficient $O(1)$ lookup for dependency changes.useState in Modern React (2026)useState is a fundamental React Hook that enables functional components to maintain state across re-renders. It returns a pair: the current state value and a dispatch function to update it. By leveraging Fiber architecture, React tracks the order of hook calls via a linked list stored on the memoizedState property of the fiber node.
useStateuseStateuseState (e.g., useState(() => expensiveCalculation())) ensures the function executes only during the initial mount. This prevents unnecessary overhead during subsequent render cycles, which occur with $O(n)$ complexity relative to the state tree size.useState is indexed by its position in the component's hook list. Conditional execution of hooks is strictly forbidden; breaking this rule causes an architectural mismatch in the linked list, leading to state corruption.When the new state is derived from the previous state, pass an updater function to avoid stale closures. This pattern is mandatory for Concurrent React environments to ensure consistent state transitions.
import { useState } from 'react';
const Counter = () => {
// 2026 Best Practice: Using an arrow function for atomic updates
const [count, setCount] = useState(0);
return (
<button onClick={() => setCount((prev) => prev + 1)}>
Count: {count}
</button>
);
};
Updating state triggers a Reconciliation process. React compares the new state with the previous state using Object.is. If they are identical, React performs a bailout, preventing a re-render of the component and its children. The time complexity for this check is $O(1)$.
React enforces unidirectional data flow, where data descends the tree via props. Updating Parent state from a Child component is fundamentally achieved via Lifting State Up, leveraging callbacks or dependency injection.
Props Callback (Standard Pattern): The parent passes a memoized handler function (e.g., useCallback) as a prop. The child invokes this function to trigger a state update in the parent.
Context API (via State-Reducer Pattern): Use createContext coupled with useReducer to provide a state dispatcher. This avoids "prop drilling" in deep component trees and is the preferred 2026 standard for intermediate-scale state sharing.
Imperative Handle (useImperativeHandle): Used with forwardRef to expose specific imperative methods to a parent. This is preferred over direct reference manipulation, allowing the parent to trigger child logic while maintaining encapsulation.
State Management Libraries (Zustand/TanStack Store): For complex global state, Zustand is the industry standard (2026) due to its minimal boilerplate and atomic updates. Redux Toolkit remains viable for large-scale enterprise systems, while MobX is largely relegated to legacy maintenance.
Server State (TanStack Query/SWR): Do not use local/global state for server data. Use TanStack Query to synchronize client-side state with the server, ensuring automatic cache invalidation and mutation handling.
// Parent.jsx
import { useState, useCallback } from 'react';
import { Child } from './Child';
export const Parent = () => {
const [data, setData] = useState('');
// useCallback prevents unnecessary re-renders of the child
const handleUpdate = useCallback((newValue) => {
setData(newValue);
}, []);
return <Child onUpdate={handleUpdate} />;
};
// Child.jsx
import { memo } from 'react';
// memo ensures the child only re-renders if props change
export const Child = memo(({ onUpdate }) => {
return (
<button onClick={() => onUpdate('Updated via memoized callback')}>
Update Parent
</button>
);
});
When updating parent state, ensure the state is placed as low as possible in the tree to prevent unnecessary re-renders of unrelated branches. Complexity of state propagation in React is $O(n)$, where $n$ is the number of component updates. Utilize React.memo and useCallback to maintain an amortized update cost of $O(1)$ relative to the total component count.
Lifting State Up is the architectural pattern of moving local component state to a common ancestor to synchronize data across multiple dependent components. This enforces a unidirectional data flow, ensuring that changes propagate downward through props while maintaining a Single Source of Truth (SSOT).
In modern React (19+), functional components and hooks have superseded class-based components. State is managed via useState and synchronized via prop drilling or React Context for deep component trees.
RectangleAreaCalculatorimport { useState } from 'react';
const RectangleAreaCalculator = () => {
const [dimensions, setDimensions] = useState({ width: 0, height: 0 });
const handleChange = (e) => {
const { name, value } = e.target;
setDimensions(prev => ({ ...prev, [name]: Number(value) }));
};
return (
<section>
<ShapeInput name="width" value={dimensions.width} onChange={handleChange} />
<ShapeInput name="height" value={dimensions.height} onChange={handleChange} />
<ShapeArea area={dimensions.width * dimensions.height} />
</section>
);
};
ShapeInput and ShapeAreaconst ShapeInput = ({ name, value, onChange }) => (
<div>
<label>{name.charAt(0).toUpperCase() + name.slice(1)}</label>
<input name={name} type="number" value={value} onChange={onChange} />
</div>
);
const ShapeArea = ({ area }) => <div>Area: {area}</div>;
Lifting state unnecessarily causes Prop Drilling, where intermediate components pass data they do not utilize.
props count of intermediate components by more than 3, evaluate the use of Composition (passing components as children) or a dedicated state provider.Managing application state in React 19 requires distinguishing between Global App State (frequently changing, high-frequency updates) and Dependency Injection (low-frequency updates, configuration).
In 2026, Redux Toolkit (RTK) is the mandatory interface. The legacy connect HOC is deprecated; the useSelector and useDispatch hooks are the standard for all functional components.
useEffect implementations.Context API is a dependency injection mechanism, not a state management solution. It is designed to propagate values through the tree without prop drilling.
| Feature | Redux Toolkit | Context API |
|---|---|---|
| Primary Use | Complex, high-frequency state | Configuration, Dependency Injection |
| Performance | Selective rendering (selectors) | Full subtree re-render (default) |
| Boilerplate | Moderate (standardized via RTK) | Minimal |
| DevTools | Native Time-Travel | Limited (React DevTools only) |
| Complexity | $O(1)$ to $O(log n)$ scaling | $O(n)$ rendering behavior |
Audit Conclusion: Favor Context API for global UI configurations and Redux Toolkit for application business logic, form state, and server-cache synchronization. Abandon the use of legacy class-based connect patterns in favor of the current Hook-based API.
Devinterview-io/react-interview-questions is a public repo on GitHub by Devinterview-io. π£ React interview questions and answers to help you prepare for your next technical interview in 2026.
It declares no license on GitHub. Public does not mean open source: without a license, nobody is granted the right to reuse it.
Its maker has not tagged a system, so it is unknown here. Its README says what it needs.
Open "Take it" on its page: Take My Repo writes an install plan for your machine and hands it to your AI agent (Claude Code, Codex or Cursor), which asks you before each step. Take My Repo has not tested it on any machine.
A complete computer science study plan to become a software engineer.
Its last change on GitHub was on 2026-03-16. GitHub counts 0 open issues and pull requests. Take My Repo does not judge from that whether it is maintained.
Nobody has reviewed it on Take My Repo yet, which says nothing about its quality.

Learn how to design large-scale systems. Prep for the system design interview. Includes Anki flashcards.
Flutter makes it easy and fast to build beautiful apps for mobile and beyond
f.k.a. Awesome ChatGPT Prompts. Share, discover, and collect prompts from the community. Free and open source β self-host for your organization with complete privacy.

π£ LLMs interview questions and answers to help you prepare for your next machine learning and data science interview in 2026.

π£ Python interview questions and answers to help you prepare for your next technical interview in 2026.

π£ SQL interview questions and answers to help you prepare for your next machine learning and data science interview in 2026.

π£ Pytorch interview questions and answers to help you prepare for your next machine learning and data science interview in 2026.

π£ API Design interview questions and answers to help you prepare for your next software architecture and design patterns interview in 2026.

π£ Databases interview questions and answers to help you prepare for your next software architecture and design patterns interview in 2026.
This page is also available as structured data, with the same sources and dates.
/api/v1/resources/gh/Devinterview-io/react-interview-questionsTake My Repo has not tested this on your machine. Requirements come from the project's own documentation.