Add contextTag field to Fiber type
contextTag is a bitmask that describes properties about the fiber and its subtree. For example, the AsyncUpdates flag indicates whether the subtree should use async scheduling. When a fiber is created, it inherits the bitmask of its parent.
Andrew Clark committed
Apr 14, 2017 at 16:27 UTC
f1df675b9343163f56aa22e705c3d82b7d026948
2 files changed
+41
-3
src/renderers/shared/fiber/ReactFiber.js
+21
-3
@@ -18,11 +18,11 @@ import type {ReactFragment} from 'ReactTypes';
18
import type {ReactCoroutine, ReactYield} from 'ReactCoroutine';
19
import type {ReactPortal} from 'ReactPortal';
20
import type {TypeOfWork} from 'ReactTypeOfWork';
21
+import type {TypeOfContext} from 'ReactTypeOfContext';
22
import type {TypeOfSideEffect} from 'ReactTypeOfSideEffect';
23
import type {PriorityLevel} from 'ReactPriorityLevel';
24
import type {UpdateQueue} from 'ReactFiberUpdateQueue';
25
25
-var ReactTypeOfWork = require('ReactTypeOfWork');
26
var {
27
IndeterminateComponent,
28
ClassComponent,
@@ -33,11 +33,17 @@ var {
33
CoroutineComponent,
34
YieldComponent,
35
Fragment,
36
-} = ReactTypeOfWork;
36
+} = require('ReactTypeOfWork');
37
38
var {NoWork} = require('ReactPriorityLevel');
39
40
-var {NoEffect} = require('ReactTypeOfSideEffect');
40
+var {
41
+ NoContext,
42
+} = require('ReactTypeOfContext');
43
+
44
+var {
45
+ NoEffect,
46
+} = require('ReactTypeOfSideEffect');
47
48
var {cloneUpdateQueue} = require('ReactFiberUpdateQueue');
49
@@ -110,6 +116,14 @@ export type Fiber = {
116
// The state used to create the output
117
memoizedState: any,
118
119
+ // Bitmask that describes properties about the fiber and its subtree. E.g. the
120
+ // AsyncUpdates flag indicates whether the subtree should be async-by-default.
121
+ // When a fiber is created, it inherits the contextTag of its parent.
122
+ // Additional flags can be set at creation time, but after than
123
+ // the value should remain unchanged throughout the fiber's lifetime,
124
+ // particularly before its child fibers are created.
125
+ contextTag: TypeOfContext,
126
+
127
// Effect
128
effectTag: TypeOfSideEffect,
129
@@ -197,6 +211,8 @@ var createFiber = function(tag: TypeOfWork, key: null | string): Fiber {
211
updateQueue: null,
212
memoizedState: null,
213
214
+ contextTag: NoContext,
215
+
216
effectTag: NoEffect,
217
nextEffect: null,
218
firstEffect: null,
@@ -282,6 +298,8 @@ exports.cloneFiber = function(
298
alt.memoizedProps = fiber.memoizedProps;
299
alt.memoizedState = fiber.memoizedState;
300
301
+ alt.contextTag = fiber.contextTag;
302
+
303
if (__DEV__) {
304
alt._debugID = fiber._debugID;
305
alt._debugSource = fiber._debugSource;
src/renderers/shared/fiber/isomorphic/ReactTypeOfContext.js
new
+20
@@ -0,0 +1,20 @@
1
+/**
2
+ * Copyright 2013-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ *
9
+ * @providesModule ReactTypeOfContext
10
+ * @flow
11
+ */
12
+
13
+'use strict';
14
+
15
+export type TypeOfContext = 0 | 1;
16
+
17
+module.exports = {
18
+ NoContext: 0,
19
+ AsyncUpdates: 1,
20
+};