2026最新的react面试题

好的,针对你文档中缺失的这些高频、高阶、且符合 2026 年技术趋势的考点,我为你整理了这份中英文双语背诵清单。

这些题目是区分“初级开发”和“资深/全栈开发”的关键。

 

一、 架构深度类 (Architecture & Fiber)

1. What is React Fiber and how does it achieve Concurrent Rendering?

(什么是 Fiber 及其如何实现并发渲染?)

2. Explain the difference between Render Phase and Commit Phase.

(渲染阶段与提交阶段的区别)

 

二、 Hooks 进阶类 (Advanced Hooks)

3. What is the 'Stale Closure' problem in Hooks and how to solve it?

(什么是 Hooks 里的“闭包陷阱”以及如何解决?)

4. What is the difference between useEffect and useLayoutEffect?

(useEffect 和 useLayoutEffect 的区别)

 

三、 现代全栈类 (Next.js & Server Components)

5. Server Components vs Client Components: When to use which?

(服务端组件与客户端组件:如何选择?)

6. What is Hydration and why does 'Hydration Mismatch' occur?

(什么是水合以及为什么会发生水合失效?)

7. How do Server Actions work in React 19 / Next.js 16?

(Server Actions 在 React 19/Next.js 16 中如何工作?)

 

四、 性能优化类 (Performance)

8. How to prevent unnecessary re-renders when using Context API?

(如何防止使用 Context 时的不必要渲染?)

原理类问题

针对 React 的高级面试,面试官通常不再关注基础 API 的使用,而是倾向于考察底层机制、性能瓶颈、复杂状态管理以及框架设计哲学

这里我为你整理了一份 React 高级/资深面试题清单,分为四个核心维度:

1. 渲染与并发机制 (Fiber & Concurrent)

Fiber 树的遍历: 既然 Fiber 是链表结构,它是如何实现深度优先遍历的?childsiblingreturn 指针分别起什么作用?

English: React Fiber uses a Linked List structure to perform a Depth-First Search (DFS).

中文: React Fiber 使用链表结构来实现深度优先遍历 (DFS)

合成事件系统: React 为什么要自己实现一套事件系统?React 17 之后事件委托的挂载点发生了什么变化?为什么?

English: React implements SyntheticBaseEvent for cross-browser compatibility and performance optimization (via event delegation).

中文: React 实现合成事件是为了跨浏览器兼容性和性能优化(通过事件委托)。

Lanes 模型: React 18 如何通过 Lanes(车道模型)来管理任务优先级?它解决了以前 ExpirationTime 模型的什么痛点?

English: The Lanes model represents different types of updates using 32-bit binary integers (bits).

中文: Lanes 模型使用 32 位二进制整数(位图)来表示不同类型的更新。

双缓存技术: React 运行时的 current 树和 workInProgress 树是如何交替切换的?

English: React Fiber uses Double Buffering to manage updates.

中文: React Fiber 使用双缓存管理更新。

2. 状态与生命周期 (Hooks & State)

Hooks 的闭包陷阱: 为什么在 useEffectuseCallback 中拿到的状态可能是旧值?除了 useRef,还有什么工程化的手段可以规避?

English: A Stale Closure occurs when a Hook captures state from an old render cycle.

中文: 闭包陷阱是指 Hook 捕获了旧渲染周期中的状态。

useState 的实现: 如果让你手写一个极简的 Hooks 调度,它是如何保证每次渲染时 Hook 的执行顺序和数据对应的?

English: React relies on a stable call order. Internally, Fiber stores Hooks as a Linked List. During every render, React keeps an index pointer. Each useX call fetches the next Hook node in the list. If you call Hooks inside if statements, the order breaks, leading to React fetching the wrong state for the wrong Hook.

中文: React 依赖于稳定的调用顺序。在内部,Fiber 将 Hooks 存储为单向链表。每次渲染时,React 维护一个指针。每个 useX 调用都会按顺序获取链表中的下一个 Hook 节点。如果你在 if 语句中调用 Hook,顺序就会被打乱,导致 React 为错误的 Hook 获取了错误的状态。

批量更新 (Batching): React 18 的 Automatic Batching 相比之前版本有哪些提升?在什么情况下它不会自动合并更新?

English: In React 18, Automatic Batching merges multiple state updates into a single re-render, even inside Promises, setTimeout, or native event handlers.

中文: 在 React 18 中,自动批处理将多个状态更新合并为一次重渲染,即使是在 Promise、setTimeout 或原生事件处理程序中。

useLayoutEffect vs useEffect: 它们在浏览器渲染流程中的具体执行时机有什么区别?在什么场景下必须使用前者?

English:

中文:

3. 性能优化与架构 (Optimization)

Diff 算法的局限性: 既然 Diff 是 ,为什么在处理跨层级移动节点时,React 会选择直接销毁并重建?

English:

To keep the Diff algorithm at complexity, React assumes that components at different levels are different. Searching the whole tree for a moved node would be . React sacrifices local performance for global speed; it unmounts the old subtree and mounts a new one at the new location.

中文:

为了保持 Diff 算法 的复杂度,React 假设不同层级的组件是不同的。在整棵树中搜索移动的节点复杂度将达到 。React 牺牲了局部性能来换取整体速度:它会直接卸载旧子树并在新位置挂载新子树。

Context 的性能瓶颈: 当 Provider 的 value 发生变化时,所有消费该 Context 的组件都会重新渲染。在不拆分 Provider 的前提下,有哪些方案可以优化?

English:

  1. Split the component: Move the part that consumes Context into a child and wrap it in React.memo.
  2. Use composition: Pass the static part of the UI as children.
  3. useMemo inside the component: Wrap the expensive UI return in useMemo, depending only on the specific field from Context.

中文:

  1. 拆分组件:将消费 Context 的部分提取到子组件并用 React.memo 包裹。
  2. 使用组合模式:将 UI 的静态部分作为 children 传入。
  3. 组件内 useMemo:将昂贵的 UI 渲染结果用 useMemo 包裹,仅依赖于 Context 中的特定字段。

Keep-Alive 的实现: React 官方目前没有提供类似 Vue 的 <keep-alive>,如果是你,你会如何设计一个能缓存组件状态和 DOM 的方案?

English: Since React doesn't have a built-in Keep-Alive, we can:

  1. CSS approach: Use display: none to hide the component without unmounting.
  2. Portal approach: Use createPortal to render the component into a "hidden DOM container" in memory, and then "teleport" it back to the visible tree when needed. This preserves both DOM state and React internal state.

中文: 由于 React 没有内置 Keep-Alive,我们可以:

  1. CSS 方案:使用 display: none 隐藏组件而不卸载。
  2. Portal 方案:使用 createPortal 将组件渲染到内存中的“隐藏 DOM 容器”,并在需要时将其“传送”回可见树。这可以同时保留 DOM 状态和 React 内部状态。

HOC vs Render Props vs Hooks: 随着 React 的演进,这三种逻辑复用模式分别解决了什么问题,又各自带来了什么副作用?

English:

中文:

4. 现代 React 与生态 (Server Components & SSR)

Server Components (RSC): 它与传统的 SSR(服务端渲染)有什么本质区别?为什么说它能极大地减少客户端的 Bundle Size?

English: SSR sends HTML to the client for faster initial viewing, but still requires the full JS bundle for hydration. RSC sends a serialized JSON and never sends its code to the client. This means heavy libraries used in RSC stay on the server, resulting in Zero Bundle Size for those components.

中文: SSR 将 HTML 发送给客户端以实现快速首屏,但仍需下载全量 JS 进行水合。RSC 发送的是序列化 JSON,且其代码永远不会发送到客户端。这意味着在 RSC 中使用的大型库都留在服务端,从而实现这些组件的零包体积

Hydration (注水): 什么是“水合失效”?在 Next.js 等框架中,为什么会出现服务端和客户端渲染内容不一致的报错?

English: Hydration is when React "attaches" interactivity to server-rendered HTML. Hydration Mismatch occurs when the client-rendered UI is different from the server-rendered HTML.

中文: 水合是 React 将交互性“绑定”到服务端渲染的 HTML 上的过程。水合失效是指客户端渲染的 UI 与服务端返回的 HTML 不一致。

Suspense 的原理: Suspense 是如何通过捕获 Promise 来实现加载状态切换的?它在并发模式下扮演了什么角色?

English: When a component is not ready (loading data), it throws a Promise. Suspense catches this promise in its "Error Boundary-like" mechanism, renders the fallback UI, and waits. When the Promise resolves, React re-tries the render. In Concurrent mode, this allows React to work on multiple UI versions without freezing the main thread.

中文: 当组件未就绪(正在加载数据)时,它会抛出(throw)一个 PromiseSuspense 在其类似于错误边界的机制中捕获这个 Promise,渲染 fallback UI 并等待。当 Promise 完成时,React 会重新尝试渲染。在并发模式下,这允许 React 同时处理多个 UI 版本而不阻塞主线程。