Tightened up Fiber | null type in ReactFiberStack to always require Fiber
Brian Vaughn committed
Dec 21, 2016 at 10:14 UTC
0b7c5ff1a08826e044d865317bc37ae4f4b63b7f
3 files changed
+15
-13
src/renderers/shared/fiber/ReactFiberCompleteWork.js
+1
-1
@@ -303,7 +303,7 @@ module.exports = function<T, P, I, TI, C, CX>(
303
// TODO: Only mark this as an update if we have any pending callbacks.
304
markUpdate(workInProgress);
305
workInProgress.memoizedProps = workInProgress.pendingProps;
306
- popHostContainer();
306
+ popHostContainer(workInProgress);
307
return null;
308
309
// Error cases
src/renderers/shared/fiber/ReactFiberHostContext.js
+12
-10
@@ -28,9 +28,9 @@ const {
28
export type HostContext<C, CX> = {
29
getHostContext() : CX,
30
getRootHostContainer() : C,
31
- popHostContainer() : void,
31
+ popHostContainer(fiber : Fiber) : void,
32
popHostContext(fiber : Fiber) : void,
33
- pushHostContainer(container : C) : void,
33
+ pushHostContainer(fiber : Fiber, container : C) : void,
34
pushHostContext(fiber : Fiber) : void,
35
resetHostContainer() : void,
36
};
@@ -53,21 +53,21 @@ module.exports = function<T, P, I, TI, C, CX>(
53
return rootInstanceStackCursor.current;
54
}
55
56
- // TODO (bvaughn) Pass the host container fiber to push()
57
- function pushHostContainer(nextRootInstance : C) {
56
+ function pushHostContainer(fiber : Fiber, nextRootInstance : C) {
57
// Push current root instance onto the stack;
58
// This allows us to reset root when portals are popped.
60
- push(rootInstanceStackCursor, nextRootInstance, null);
59
+ push(rootInstanceStackCursor, nextRootInstance, fiber);
60
61
const nextRootContext = getRootHostContext(nextRootInstance);
62
64
- push(contextStackCursor, nextRootContext, null);
63
+ // TODO (bvaughn) Push context-providing Fiber with its own cursor
64
+ push(contextStackCursor, nextRootContext, fiber);
65
}
66
67
- // TODO (bvaughn) Pass the host container fiber to pop()
68
- function popHostContainer() {
69
- pop(contextStackCursor, null);
70
- pop(rootInstanceStackCursor, null);
67
+ function popHostContainer(fiber : Fiber) {
68
+ pop(contextStackCursor, fiber);
69
+ // TODO (bvaughn) Pop context-providing Fiber with its own cursor
70
+ pop(rootInstanceStackCursor, fiber);
71
}
72
73
function getHostContext() : CX {
@@ -91,6 +91,7 @@ module.exports = function<T, P, I, TI, C, CX>(
91
return;
92
}
93
94
+ // TODO (bvaughn) Push context-providing Fiber with its own cursor
95
push(contextStackCursor, nextContext, fiber);
96
}
97
@@ -99,6 +100,7 @@ module.exports = function<T, P, I, TI, C, CX>(
100
return;
101
}
102
103
+ // TODO (bvaughn) Check context-providing Fiber and only pop if it matches
104
pop(contextStackCursor, fiber);
105
}
106
src/renderers/shared/fiber/ReactFiberStack.js
+2
-2
@@ -40,7 +40,7 @@ exports.isEmpty = function() : boolean {
40
41
exports.pop = function<T>(
42
cursor : StackCursor<T>,
43
- fiber: Fiber | null, // TODO (bvaughn) Tighten up this type to only accept Fiber
43
+ fiber: Fiber,
44
) : void {
45
if (index < 0) {
46
if (__DEV__) {
@@ -71,7 +71,7 @@ exports.pop = function<T>(
71
exports.push = function<T>(
72
cursor : StackCursor<T>,
73
value : any,
74
- fiber: Fiber | null, // TODO (bvaughn) Tighten up this type to only accept Fiber
74
+ fiber: Fiber,
75
) : void {
76
cursor.current = value;
77