摘要:什么是每一个都有一个对应的,记录这个节点的各种状态,是一链表的结构的串联起来。
1. 什么是fiber
每一个ReactElement都有一个对应的fiber, 记录这个节点的各种状态, fiber是一链表的结构的串联起来。
export type Fiber = {|
// Tag identifying the type of fiber.
//区分fiber的种类
tag: WorkTag,
// Unique identifier of this child.
// 像react元素中的唯一的key
key: null | string,
// The value of element.type which is used to preserve the identity during
// reconciliation of this child.
//就是creatElement的第一个值,用来在子节点reconciliation阶段的标识
elementType: any,
// The resolved function/class/ associated with this fiber.
//异步组件加载resovled后种类是函数式还是类
type: any,
// The local state associated with this fiber.
//与这个fiber联系的本地状态,指向实例
stateNode: any,
// It is conceptually the same as the return address of a stack frame.
// 指向 Fiber Tree 中的父节点
return: Fiber | null,
// Singly Linked List Tree Structure.
// 指向第一个子节点
child: Fiber | null,
// 指向兄弟节点
sibling: Fiber | null,
index: number,
// The ref last used to attach this node.
// I"ll avoid adding an owner field for prod and model that as functions.
ref: null | (((handle: mixed) => void) & {_stringRef: ?string}) | RefObject,
// Input is the data coming into process this fiber. Arguments. Props.
//新的即将进来的props
pendingProps: any, // This type will be more specific once we overload the tag.
// 现在的已经展示在UI上的props
memoizedProps: any, // The props used to create the output.
// A queue of state updates and callbacks.
// 保存更新的状态和回调函数
updateQueue: UpdateQueue | null,
// The state used to create the output
// 展示在UI中的state
memoizedState: any,
// A linked-list of contexts that this fiber depends on
contextDependencies: ContextDependencyList | null,
mode: TypeOfMode,
// Effect
//副作用
effectTag: SideEffectTag,
// Singly linked list fast path to the next fiber with side-effects.
// 单链表结构,方便遍历 Fiber Tree 上有副作用的节点
nextEffect: Fiber | null,
// The first and last fiber with side-effect within this subtree. This allows
// us to reuse a slice of the linked list when we reuse the work done within
// this fiber.
//在子节点中的第一个和最后一个的副作用,这个可以允许我们进行切片的复用
firstEffect: Fiber | null,
lastEffect: Fiber | null,
// Represents a time in the future by which this work should be completed.
// Does not include work found in its subtree.
expirationTime: ExpirationTime,
// This is used to quickly determine if a subtree has no pending changes.
childExpirationTime: ExpirationTime,
// This is a pooled version of a Fiber. Every fiber that gets updated will
// eventually have a pair. There are cases when we can clean up pairs to save
// memory if we need to.
alternate: Fiber | null,
// Time spent rendering this Fiber and its descendants for the current update.
// This tells us how well the tree makes use of sCU for memoization.
// It is reset to 0 each time we render and only updated when we don"t bailout.
// This field is only set when the enableProfilerTimer flag is enabled.
actualDuration?: number,
// If the Fiber is currently active in the "render" phase,
// This marks the time at which the work began.
// This field is only set when the enableProfilerTimer flag is enabled.
actualStartTime?: number,
// Duration of the most recent render time for this Fiber.
// This value is not updated when we bailout for memoization purposes.
// This field is only set when the enableProfilerTimer flag is enabled.
selfBaseDuration?: number,
// Sum of base times for all descedents of this Fiber.
// This value bubbles up during the "complete" phase.
// This field is only set when the enableProfilerTimer flag is enabled.
treeBaseDuration?: number,
// Conceptual aliases
// workInProgress : Fiber -> alternate The alternate used for reuse happens
// to be the same as work in progress.
// __DEV__ only
_debugID?: number,
_debugSource?: Source | null,
_debugOwner?: Fiber | null,
_debugIsCurrentlyTiming?: boolean,
// Used to verify that the order of hooks does not change between renders.
_debugHookTypes?: Array | null,
|};
文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。
转载请注明本文地址:https://www.ucloud.cn/yun/103269.html
摘要:因为版本将真正废弃这三生命周期到目前为止,的渲染机制遵循同步渲染首次渲染,更新时更新时卸载时期间每个周期函数各司其职,输入输出都是可预测,一路下来很顺畅。通过进一步观察可以发现,预废弃的三个生命周期函数都发生在虚拟的构建期间,也就是之前。 showImg(https://segmentfault.com/img/bVbweoj?w=559&h=300); 背景 前段时间准备前端招聘事项...
摘要:浅谈网站性能之前端性能优化性能优化的目的无非是减少用户流量消耗,提升用户首屏体验,提升用户访问速度,让用户专注内容本身。前端性能优化减少请求数量基本原理在浏览器与服务器进行通信时,主要是通过进行通信。 最近项目慢慢走上正轨,需求趋于平稳,这才想起需要对整站进行性能优化。经过一段时间的学习,结合现在项目的实际性能情况,发现确实有许多地方可以进行优化。于是就开始了我的前端性能优化之旅。以下...
摘要:浅谈网站性能之前端性能优化性能优化的目的无非是减少用户流量消耗,提升用户首屏体验,提升用户访问速度,让用户专注内容本身。前端性能优化减少请求数量基本原理在浏览器与服务器进行通信时,主要是通过进行通信。 最近项目慢慢走上正轨,需求趋于平稳,这才想起需要对整站进行性能优化。经过一段时间的学习,结合现在项目的实际性能情况,发现确实有许多地方可以进行优化。于是就开始了我的前端性能优化之旅。以下...
摘要:杰出的数据库迁移工具和紧密集成的单元测试支持,这些工具赋予你构建任何应用的能力。浅谈应公司要求,现在用重新搭一个框架,接触了几天对它也有了一定的了解。浅谈支持,支持单元测试。更加严谨了,异常严谨的错误检测和安全机制。 自从接触php开始,用的就是thinkphp框架,它给我的感觉是轻量,且容易上手。后来进了一家外包公司又用了laravel框架,个人觉得laravel还是很高大上的,功能...
摘要:浅谈前端优化的几个思路雪碧图页面中如果有很多图片小图标这样会有很多请求一个图就是一个请求建立连接进行三次握手这些都是耗费时间的如果页面很多可以考虑用精灵汽水雪碧也是这个单词技术做一张雪碧图将请求多个变成一次请求可以用来配置实现懒加载如果页面 浅谈前端优化的几个思路 https://ltoddy.github.io 雪碧图 页面中如果有很多图片、icon(小图标),这样会有很多HTTP请...
阅读 3130·2021-11-24 09:39
阅读 5017·2021-10-27 14:19
阅读 2303·2021-08-12 13:25
阅读 2547·2019-08-29 17:07
阅读 1284·2019-08-29 13:44
阅读 1339·2019-08-26 12:17
阅读 721·2019-08-23 17:16
阅读 2293·2019-08-23 16:46