NoWork = 0

noTimeout = undefined

HostRoot = 3

NoContext = 0b000;

AsyncMode = 0b001;

StrictMode = 0b010;

ProfileMode = 0b100;

NoEffect = /*              */ 0b00000000000

enableProfilerTimer = __PROFILE__

__PROFILE__: true

isDevToolsPresent =  typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined'

一、制造root._internalRoot 的 createFiberRoot 方法 

 1 export function createFiberRoot(
 2   containerInfo: any,  // id=app 的 dom
 3   isAsync: boolean, // false
 4   hydrate: boolean, // false
 5 ): FiberRoot {
 6   const uninitializedFiber = createHostRootFiber(isAsync);
 7   const root = {
 8     current: uninitializedFiber, // 添加fiber 属性 一直用它
 9     containerInfo: containerInfo, // dom app
10     pendingChildren: null,
11 
12     earliestPendingTime: NoWork,
13     latestPendingTime: NoWork,
14     earliestSuspendedTime: NoWork,
15     latestSuspendedTime: NoWork,
16     latestPingedTime: NoWork,
17 
18     didError: false,
19 
20     pendingCommitExpirationTime: NoWork,
21     finishedWork: null,
22     timeoutHandle: noTimeout,
23     context: null,
24     pendingContext: null,
25     hydrate, //false
26     nextExpirationTimeToWorkOn: NoWork,
27     expirationTime: NoWork,
28     firstBatch: null,
29     nextScheduledRoot: null,
30   };
31   uninitializedFiber.stateNode = root;
32   return root;
33 }
View Code

相关文章:

  • 2022-12-23
  • 2021-11-06
  • 2022-12-23
  • 2021-04-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-28
  • 2022-12-23
  • 2022-12-23
  • 2021-11-26
  • 2021-06-02
相关资源
相似解决方案