89
90
if (__DEV__) {
91
const name = getComponentName(workInProgress) || 'Unknown';
92
- ReactDebugCurrentFiber.setCurrentFiber(workInProgress, null);
92
checkPropTypes(
93
contextTypes,
94
context,
96
name,
97
ReactDebugCurrentFiber.getCurrentFiberStackAddendum,
98
);
100
- ReactDebugCurrentFiber.resetCurrentFiber();
99
}
100
101
// Cache unmasked context so we can avoid recreating masked context unless necessary.
151
push(didPerformWorkStackCursor, didChange, fiber);
152
};
153
156
-function processChildContext(
157
- fiber: Fiber,
158
- parentContext: Object,
159
- isReconciling: boolean,
160
-): Object {
154
+function processChildContext(fiber: Fiber, parentContext: Object): Object {
155
const instance = fiber.stateNode;
156
const childContextTypes = fiber.type.childContextTypes;
157
178
179
let childContext;
180
if (__DEV__) {
187
- ReactDebugCurrentFiber.setCurrentFiber(fiber, 'getChildContext');
181
+ ReactDebugCurrentFiber.setCurrentPhase('getChildContext');
182
startPhaseTimer(fiber, 'getChildContext');
183
childContext = instance.getChildContext();
184
stopPhaseTimer();
191
- ReactDebugCurrentFiber.resetCurrentFiber();
185
+ ReactDebugCurrentFiber.setCurrentPhase(null);
186
} else {
187
childContext = instance.getChildContext();
188
}
196
}
197
if (__DEV__) {
198
const name = getComponentName(fiber) || 'Unknown';
205
- // We can only provide accurate element stacks if we pass work-in-progress tree
206
- // during the begin or complete phase. However currently this function is also
207
- // called from unstable_renderSubtree legacy implementation. In this case it unsafe to
208
- // assume anything about the given fiber. We won't pass it down if we aren't sure.
209
- // TODO: remove this hack when we delete unstable_renderSubtree in Fiber.
210
- const workInProgress = isReconciling ? fiber : null;
211
- ReactDebugCurrentFiber.setCurrentFiber(workInProgress, null);
199
checkPropTypes(
200
childContextTypes,
201
childContext,
202
'child context',
203
name,
204
+ // In practice, there is one case in which we won't get a stack. It's when
205
+ // somebody calls unstable_renderSubtreeIntoContainer() and we process
206
+ // context from the parent component instance. The stack will be missing
207
+ // because it's outside of the reconciliation, and so the pointer has not
208
+ // been set. This is rare and doesn't matter. We'll also remove that API.
209
ReactDebugCurrentFiber.getCurrentFiberStackAddendum,
210
);
219
- ReactDebugCurrentFiber.resetCurrentFiber();
211
}
212
213
return {...parentContext, ...childContext};
255
// Merge parent and own context.
256
// Skip this if we're not updating due to sCU.
257
// This avoids unnecessarily recomputing memoized values.
267
- const mergedContext = processChildContext(
268
- workInProgress,
269
- previousContext,
270
- true,
271
- );
258
+ const mergedContext = processChildContext(workInProgress, previousContext);
259
instance.__reactInternalMemoizedMergedChildContext = mergedContext;
260
261
// Replace the old (or empty) context with the new one.