@@ -89,13 +89,6 @@ exports.getMaskedContext = function(
8989
9090 if ( __DEV__ ) {
9191 const name = getComponentName ( workInProgress ) || 'Unknown' ;
92- if ( workInProgress !== ReactDebugCurrentFiber . current ) {
93- warning (
94- false ,
95- 'Expected the work in progress to match the currently processed fiber. ' +
96- 'This error is likely caused by a bug in React. Please file an issue.' ,
97- ) ;
98- }
9992 checkPropTypes (
10093 contextTypes ,
10194 context ,
@@ -158,11 +151,7 @@ exports.pushTopLevelContextObject = function(
158151 push ( didPerformWorkStackCursor , didChange , fiber ) ;
159152} ;
160153
161- function processChildContext (
162- fiber : Fiber ,
163- parentContext : Object ,
164- isReconciling : boolean ,
165- ) : Object {
154+ function processChildContext ( fiber : Fiber , parentContext : Object ) : Object {
166155 const instance = fiber . stateNode ;
167156 const childContextTypes = fiber . type . childContextTypes ;
168157
@@ -189,19 +178,11 @@ function processChildContext(
189178
190179 let childContext ;
191180 if ( __DEV__ ) {
192- // TODO: we only have to store the "previous" fiber and phase and restore them
193- // because this method can be called outside of reconciliation. We can remove this
194- // when we stop supporting unstable_renderSubtreeIntoContainer.
195- const previousCurrentFiber = ReactDebugCurrentFiber . current ;
196- const previousCurrentPhase = ReactDebugCurrentFiber . phase ;
197- ReactDebugCurrentFiber . setCurrentFiber ( fiber , 'getChildContext' ) ;
181+ ReactDebugCurrentFiber . setCurrentPhase ( 'getChildContext' ) ;
198182 startPhaseTimer ( fiber , 'getChildContext' ) ;
199183 childContext = instance . getChildContext ( ) ;
200184 stopPhaseTimer ( ) ;
201- ReactDebugCurrentFiber . setCurrentFiber (
202- previousCurrentFiber ,
203- previousCurrentPhase ,
204- ) ;
185+ ReactDebugCurrentFiber . setCurrentPhase ( null ) ;
205186 } else {
206187 childContext = instance . getChildContext ( ) ;
207188 }
@@ -215,29 +196,18 @@ function processChildContext(
215196 }
216197 if ( __DEV__ ) {
217198 const name = getComponentName ( fiber ) || 'Unknown' ;
218- // We can only provide accurate element stacks if we pass work-in-progress tree
219- // during the begin or complete phase. However currently this function is also
220- // called from unstable_renderSubtree legacy implementation. In this case it unsafe to
221- // assume anything about the given fiber. We won't pass it down if we aren't sure.
222- // TODO: remove this hack when we delete unstable_renderSubtree in Fiber.
223- const workInProgress = isReconciling ? fiber : null ;
224- // TODO: we only have to store the "previous" fiber and phase and restore them
225- // because this method can be called outside of reconciliation. We can remove this
226- // when we stop supporting unstable_renderSubtreeIntoContainer.
227- const previousCurrentFiber = ReactDebugCurrentFiber . current ;
228- const previousCurrentPhase = ReactDebugCurrentFiber . phase ;
229- ReactDebugCurrentFiber . setCurrentFiber ( workInProgress , null ) ;
230199 checkPropTypes (
231200 childContextTypes ,
232201 childContext ,
233202 'child context' ,
234203 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.
235209 ReactDebugCurrentFiber . getCurrentFiberStackAddendum ,
236210 ) ;
237- ReactDebugCurrentFiber . setCurrentFiber (
238- previousCurrentFiber ,
239- previousCurrentPhase ,
240- ) ;
241211 }
242212
243213 return { ...parentContext , ...childContext } ;
@@ -285,11 +255,7 @@ exports.invalidateContextProvider = function(
285255 // Merge parent and own context.
286256 // Skip this if we're not updating due to sCU.
287257 // This avoids unnecessarily recomputing memoized values.
288- const mergedContext = processChildContext (
289- workInProgress ,
290- previousContext ,
291- true ,
292- ) ;
258+ const mergedContext = processChildContext ( workInProgress , previousContext ) ;
293259 instance . __reactInternalMemoizedMergedChildContext = mergedContext ;
294260
295261 // Replace the old (or empty) context with the new one.
0 commit comments