惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
Scott Helme
Scott Helme
爱范儿
爱范儿
WordPress大学
WordPress大学
博客园 - 三生石上(FineUI控件)
阮一峰的网络日志
阮一峰的网络日志
博客园 - Franky
V
V2EX
腾讯CDC
博客园_首页
博客园 - 司徒正美
酷 壳 – CoolShell
酷 壳 – CoolShell
T
Tailwind CSS Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
小众软件
小众软件
J
Java Code Geeks
大猫的无限游戏
大猫的无限游戏
月光博客
月光博客
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog
雷峰网
雷峰网
Stack Overflow Blog
Stack Overflow Blog
IT之家
IT之家
罗磊的独立博客
Recorded Future
Recorded Future
博客园 - 聂微东
O
OpenAI News
S
Secure Thoughts
Hacker News: Ask HN
Hacker News: Ask HN
S
Schneier on Security
Hacker News - Newest:
Hacker News - Newest: "LLM"
Y
Y Combinator Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Project Zero
Project Zero
宝玉的分享
宝玉的分享
K
Kaspersky official blog
N
Netflix TechBlog - Medium
T
The Exploit Database - CXSecurity.com
Google Online Security Blog
Google Online Security Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Webroot Blog
Webroot Blog
云风的 BLOG
云风的 BLOG
Simon Willison's Weblog
Simon Willison's Weblog
C
Check Point Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
L
LINUX DO - 热门话题
美团技术团队
L
Lohrmann on Cybersecurity

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
How React Works (Part 2)? Why React Had to Build Its Own Execution Engine
Sam Abaasi · 2026-05-02 · via DEV Community

Why React Had to Build Its Own Execution Engine

Series: How React Works Under the Hood
Part 1: Motivation Behind React Fiber: Time Slicing & Suspense
Prerequisites: Read Part 1 first — this article picks up exactly where it left off.


Where We Left Off

In Part 1 we landed on one sentence that explains why React had to be completely rewritten:

React needs to be able to interrupt what it's doing and resume it later.

Time Slicing needs it — to yield within the browser's 16ms frame budget.
Suspense needs it — to pause and wait for async data.

Simple enough requirement. But here's the problem: JavaScript itself won't let you do it.

This article is about why that's true, what React did about it, and why that decision — building an entirely custom execution model — is what makes modern React possible.


The Problem: JavaScript Runs to Completion

When JavaScript starts executing a function, it finishes it. There is no external API to say "pause here, do something else, come back." There is no way to freeze a running program mid-execution, hand control back to the browser, and resume from the exact same spot.

This is because JavaScript manages execution with something called the call stack — a data structure that tracks what the program is doing at any moment.

Every time a function is called, JavaScript creates a stack frame — a small record of that function's parameters, local variables, and where to return to when it finishes. These frames stack up as functions call other functions, and pop off as they return.

call stack growing as functions call each other, frames popping as they return

Here's the critical property of this stack: it's managed entirely by the JavaScript engine. You — the developer — cannot read it, pause it, or jump around in it. It's a black box. Once a chain of function calls starts, it runs to completion. The browser can't paint. The user can't interact. Nothing happens until the stack is empty.

For old React, this was fine. React rendered your whole tree in one big chain of function calls. The browser waited. Nobody noticed because apps were small enough.

But for Time Slicing — where React needs to stop mid-render, let the browser paint, then resume — this model is a hard wall. You can see the exact moment React solved it in two lines from the React source:

// Old — no way out until every component is done
function workLoopSync() {
  while (workInProgress !== null) {
    performUnitOfWork(workInProgress);
  }
}

// New — checks after every single component
function workLoopConcurrent() {
  while (workInProgress !== null && !shouldYield()) {
    performUnitOfWork(workInProgress);
  }
}

Enter fullscreen mode Exit fullscreen mode

One extra condition: !shouldYield(). That's it. After every component, React asks: "Is the browser waiting? Is there higher-priority work?" If yes, the loop breaks. But for this to be safe — for breaking mid-loop to not lose work — React needed somewhere to store what it was doing. That storage is Fiber.

Sam Galson described it precisely in his talk "Magic in the web of it":

"Unlike stack frames, fibers can also keep around local data like state even if they're not currently active. With a stack frame, when it's popped off the stack, all of the local information stored in it is gone. But that's not the case with a fiber."


The Insight: What If React Had Its Own Stack?

Here's the idea that changed everything.

The native JavaScript call stack is a constraint because React doesn't control it. But what if React built its own version — one that it does control?

Not a replacement for JavaScript's stack. JavaScript still runs normally. But React would track its own rendering work in a data structure it manages itself. One it can pause, inspect, prioritize, and resume at any moment.

This is what React Fiber is. It is React's own custom execution model, built in plain JavaScript objects, sitting on top of JavaScript's normal execution.

Sam Galson described the CS concept behind it:

"A fiber is just a generic way to model program execution in a way where each individual unit of work works together cooperatively. No single fiber attempts to dominate the program."

React didn't invent this idea. Fibers exist in operating systems. Microsoft Windows uses them. OCaml built its entire concurrency model on them. The concept is old — React just brought it to the browser.


What a Fiber Actually Is

In JavaScript's call stack, a stack frame holds:

  • What function is running
  • What parameters it was called with
  • What local variables it has
  • Where to return to when done

A Fiber holds the exact same information — but for a React component:

Stack frame Fiber equivalent
The function Your component (App, Button, etc.)
Parameters Props being passed in
Local variables State and hooks
Return address The parent component

The difference that makes everything possible: stack frames live inside the JavaScript engine where you can't touch them. Fibers are just plain JavaScript objects. React creates them, reads them, pauses on them, and resumes them — completely under its own control.

Here's what a fiber for a <Button> component actually looks like at runtime:

{
  type: Button,              // your component function
  pendingProps: { label: "click me" },  // props coming in
  memoizedState: { count: 0 },          // state lives here
  return: ParentFiber,       // parent — like a return address
  child: null,               // first child component
  sibling: null,             // next sibling component
  alternate: null,           // the other version of this fiber
}

Enter fullscreen mode Exit fullscreen mode

That's it. A regular JavaScript object. Nothing magical. The fact that it's just an object is what makes pausing safe — React can stop at any point, and the fiber is still sitting in memory exactly as it was.

And because fibers are objects, they can hold more than stack frames can. Each fiber knows not just its parent (like a return address) but also its first child and its next sibling. This means React can navigate the entire component tree from any point — forward, backward, sideways — without losing track of where it is.

When the browser needs to paint, React stops updating workInProgress (its pointer to the current fiber), yields control, and returns to the work loop later. The fiber is still sitting in memory, exactly as React left it. Nothing was lost.


Two Trees, Always

Here's one more piece of the picture that makes this safe.

React always keeps two versions of your component tree in memory at the same time:

  • The current tree — what's actually showing on screen right now
  • The work-in-progress tree — what React is building for the next render

All rendering work happens on the work-in-progress tree. The current tree is never touched during rendering. So if React gets interrupted mid-render, the screen doesn't flicker or break — the current tree is still intact and showing correctly.

When the new tree is fully built and ready, React swaps them in one atomic operation. What was work-in-progress becomes current. What was current becomes the next work-in-progress (ready to be reused for the render after that).

two trees — current (on screen) and work-in-progress (being built), swap on commit

This pattern — keeping two versions and building the new one safely before switching — is called double buffering. It's the same technique video games use to prevent screen tearing. React borrowed it for exactly the same reason: you never want to show the user a half-built state.


How the Scheduler Uses This

Now the Scheduler — the module that decides when and in what order work runs — can do things that were completely impossible before.

Pause and resume. When shouldYield() returns true (time budget used up), the work loop simply stops. The workInProgress pointer stays exactly where it is. Next time the Scheduler gets control, the loop continues from that fiber. No work is lost. No state is rebuilt.

Prioritize. Because fibers are objects React controls, it can look at any fiber's priority (lanes) and decide to work on a different part of the tree first. A keystroke comes in while React is rendering a heavy chart? React stops the chart render, handles the keystroke (which runs at higher priority), then comes back to the chart from exactly where it left off.

Abort. If a newer update makes the current work-in-progress tree obsolete, React can throw it away entirely and start fresh with updated data. The current tree on screen is unaffected.

None of these were possible when rendering was one continuous chain of JavaScript function calls.

Scheduler work loop — shouldYield check, pause, high-priority task runs, resume


The Full Picture in One Paragraph

React saw that JavaScript's call stack — fast, simple, but completely opaque — was incompatible with the kind of interruptible, prioritized rendering that modern apps need. So it built a replacement: a tree of plain JavaScript objects (fibers) where each object is a stack frame React controls. It keeps two copies of this tree so it can always build the next version safely without disturbing what's on screen. And it has a Scheduler that decides what to work on next, how long to work before yielding, and how to resume exactly where it stopped.

That system — Fiber + Scheduler — is the engine underneath every useState, every useTransition, every <Suspense> boundary, every animation that doesn't drop frames.


What's Coming in Part 3

Now that we understand the engine, we can look at what the engine actually does — how React figures out which parts of your UI actually changed, and how it updates the minimum number of DOM nodes to reflect that. That's the Reconciler, and it's where key props, React.memo, and most of your performance intuitions come from.


🎬 Watch These

Sam Galson — Magic in the web of it: coroutines, continuations, fibers | React Advanced London
The computer science behind why Fiber works — what fibers are in CS terms, how they differ from threads and coroutines, and why React chose this model. The source for the cooperative execution framing in this article.

Dan Abramov — Beyond React 16 | JSConf Iceland 2018
The original demo of the problem this article solves. Watch 2:57 to feel exactly why the call stack was a problem.

Matheus Albuquerque — Inside Fiber | React Summit 2022
Goes deeper on the FiberNode data structure if you want the implementation detail. Start at 2:11.


🙏 Sources & Thanks

  • Sam GalsonMagic in the web of it (talk) and Continuations, coroutines, fibers, effects (article). The cooperative execution framing, the "fibers existed before React" point, and the comparison between fibers and stack frames all come from Sam's work.
  • Andrew Clarkreact-fiber-architecture. The definition of Fiber as "a reimplementation of the stack, specialized for React components" and the double buffering concept.
  • jser.dev — source-level verification of how the two-tree system, workInProgress, and the Scheduler work loop actually behave in the React codebase.

Part 3 is next — the Reconciler: how React finds the minimum set of changes needed to update your UI, and why key props matter more than you think. 🔧


Tags: #react #javascript #webdev #tutorial