Giter VIP home page Giter VIP logo

Comments (7)

jacty avatar jacty commented on May 18, 2024

当 completedWork.flags 的值表示还有“副作用”存在的话进入下一个循环查找该“副作用”存在于哪个Fiber 上并进行相应的增删改查处理。

from react-illustration-series.

7kms avatar 7kms commented on May 18, 2024

这里确切来讲是异常判断, completeUnitOfWork正常来讲就是深度优先遍历的回溯阶段会调用.
特殊情况就是在beginWork阶段发生异常, 也会调用, 这时候completeWork.flags中会包含Incomplete. 所以这里有个if判断, 不同情况下的处理不一样.

可以对照一下源码中的英文注释

https://github.com/facebook/react/blob/v17.0.2/packages/react-reconciler/src/ReactFiberWorkLoop.old.js#L1682

from react-illustration-series.

DaphnisLi avatar DaphnisLi commented on May 18, 2024

这里确切来讲是异常判断, completeUnitOfWork正常来讲就是深度优先遍历的回溯阶段会调用. 特殊情况就是在beginWork阶段发生异常, 也会调用, 这时候completeWork.flags中会包含Incomplete. 所以这里有个if判断, 不同情况下的处理不一样.

可以对照一下源码中的英文注释

https://github.com/facebook/react/blob/v17.0.2/packages/react-reconciler/src/ReactFiberWorkLoop.old.js#L1682

beginWork 阶段的异常情况指的是 “并没有把该 fiber 节点的所有副作用都设置到 fiber.flags 上” ?

from react-illustration-series.

7kms avatar 7kms commented on May 18, 2024

异常就是指出现了代码运行时错误, 会设置completeWork.flags |= Incomplete

from react-illustration-series.

DaphnisLi avatar DaphnisLi commented on May 18, 2024

异常就是指出现了代码运行时错误, 会设置completeWork.flags |= Incomplete

根本原因还是 报错影响了 fiber 树的构建吧?

from react-illustration-series.

7kms avatar 7kms commented on May 18, 2024

异常就是指出现了代码运行时错误, 会设置completeWork.flags |= Incomplete

根本原因还是 报错影响了 fiber 树的构建吧?

是的呀

from react-illustration-series.

creamidea avatar creamidea commented on May 18, 2024

Incomplete 目前看有 2 个情况会使用到:一个 ErrorBoundary,另一个 Suspense

from react-illustration-series.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.