Combined unwindContext and unwindHostContext into unwindContexts
Brian Vaughn committed
Dec 21, 2016 at 10:04 UTC
0c1fdfd41daaf477e05b566def55975cb82a459b
2 files changed
+15
-17
src/renderers/shared/fiber/ReactFiberContext.js
-10
@@ -159,13 +159,3 @@ exports.findCurrentUnmaskedContext = function(fiber: Fiber) : Object {
159
}
160
return node.stateNode.context;
161
};
162
-
163
-exports.unwindContext = function(from : Fiber, to: Fiber) {
164
- let node = from;
165
- while (node && (node !== to) && (node.alternate !== to)) {
166
- if (isContextProvider(node)) {
167
- popContextProvider(node);
168
- }
169
- node = node.return;
170
- }
171
-};
src/renderers/shared/fiber/ReactFiberScheduler.js
+15
-7
@@ -17,6 +17,11 @@ import type { FiberRoot } from 'ReactFiberRoot';
17
import type { HostConfig, Deadline } from 'ReactFiberReconciler';
18
import type { PriorityLevel } from 'ReactPriorityLevel';
19
20
+var {
21
+ isContextProvider,
22
+ popContextProvider,
23
+} = require('ReactFiberContext');
24
+
25
var ReactFiberBeginWork = require('ReactFiberBeginWork');
26
var ReactFiberCompleteWork = require('ReactFiberCompleteWork');
27
var ReactFiberCommitWork = require('ReactFiberCommitWork');
@@ -59,7 +64,6 @@ var {
64
65
var {
66
resetContext,
62
- unwindContext,
67
} = require('ReactFiberContext');
68
69
if (__DEV__) {
@@ -724,8 +728,7 @@ module.exports = function<T, P, I, TI, C, CX>(config : HostConfig<T, P, I, TI, C
728
// from the root. Can't do that until then because without memoized
729
// props, the nodes higher up in the tree will rerender unnecessarily.
730
if (failedWork) {
727
- unwindContext(failedWork, boundary);
728
- unwindHostContext(failedWork, boundary);
731
+ unwindContexts(failedWork, boundary);
732
}
733
nextUnitOfWork = completeUnitOfWork(boundary);
734
}
@@ -945,18 +948,23 @@ module.exports = function<T, P, I, TI, C, CX>(config : HostConfig<T, P, I, TI, C
948
}
949
}
950
948
- function unwindHostContext(from : Fiber, to: Fiber) {
951
+ function unwindContexts(from : Fiber, to: Fiber) {
952
let node = from;
953
while (node && (node !== to) && (node.alternate !== to)) {
954
switch (node.tag) {
955
+ case ClassComponent:
956
+ if (isContextProvider(node)) {
957
+ popContextProvider(node);
958
+ }
959
+ break;
960
case HostComponent:
961
popHostContext(node);
962
break;
963
case HostRoot:
956
- popHostContainer();
964
+ popHostContainer(node);
965
break;
966
case HostPortal:
959
- popHostContainer();
967
+ popHostContainer(node);
968
break;
969
}
970
node = node.return;
@@ -1118,4 +1126,4 @@ module.exports = function<T, P, I, TI, C, CX>(config : HostConfig<T, P, I, TI, C
1126
syncUpdates: syncUpdates,
1127
deferredUpdates: deferredUpdates,
1128
};
1121
-};
1129
+};
\ No newline at end of file