Skip to content

Commit 393cdbc

Browse files
committed
Consolidate ReactCurrentFiber and ReactDebugLifeCycle
1 parent d2c28be commit 393cdbc

File tree

6 files changed

+17
-47
lines changed

6 files changed

+17
-47
lines changed

src/renderers/shared/fiber/ReactDebugCurrentFiber.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
import type { Fiber } from 'ReactFiber';
1616

17+
type LifeCyclePhase = 'render' | 'getChildContext';
18+
1719
if (__DEV__) {
1820
var getComponentName = require('getComponentName');
1921
var { getStackAddendumByWorkInProgressFiber } = require('ReactComponentTreeHook');
@@ -47,6 +49,8 @@ function getCurrentFiberStackAddendum() : string | null {
4749

4850
var ReactDebugCurrentFiber = {
4951
current: (null : Fiber | null),
52+
phase: (null : LifeCyclePhase | null),
53+
5054
getCurrentFiberOwnerName,
5155
getCurrentFiberStackAddendum,
5256
};

src/renderers/shared/fiber/ReactFiberBeginWork.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ var invariant = require('invariant');
6666

6767
if (__DEV__) {
6868
var ReactDebugCurrentFiber = require('ReactDebugCurrentFiber');
69-
var ReactDebugLifeCycle = require('ReactDebugLifeCycle');
7069
var warning = require('warning');
7170
var warnedAboutStatelessRefs = {};
7271
}
@@ -231,11 +230,9 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
231230

232231
if (__DEV__) {
233232
ReactCurrentOwner.current = workInProgress;
234-
ReactDebugLifeCycle.current = workInProgress;
235-
ReactDebugLifeCycle.phase = 'render';
233+
ReactDebugCurrentFiber.phase = 'render';
236234
nextChildren = fn(nextProps, context);
237-
ReactDebugLifeCycle.current = null;
238-
ReactDebugLifeCycle.phase = null;
235+
ReactDebugCurrentFiber.phase = null;
239236
} else {
240237
nextChildren = fn(nextProps, context);
241238
}
@@ -286,11 +283,9 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
286283
ReactCurrentOwner.current = workInProgress;
287284
let nextChildren;
288285
if (__DEV__) {
289-
ReactDebugLifeCycle.current = workInProgress;
290-
ReactDebugLifeCycle.phase = 'render';
286+
ReactDebugCurrentFiber.phase = 'render';
291287
nextChildren = instance.render();
292-
ReactDebugLifeCycle.current = null;
293-
ReactDebugLifeCycle.phase = null;
288+
ReactDebugCurrentFiber.phase = null;
294289
} else {
295290
nextChildren = instance.render();
296291
}

src/renderers/shared/fiber/ReactFiberContext.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const {
3535
if (__DEV__) {
3636
var checkReactTypeSpec = require('checkReactTypeSpec');
3737
var ReactDebugCurrentFrame = require('ReactDebugCurrentFrame');
38-
var ReactDebugLifeCycle = require('ReactDebugLifeCycle');
38+
var ReactDebugCurrentFiber = require('ReactDebugCurrentFiber');
3939
var warnedAboutMissingGetChildContext = {};
4040
}
4141

@@ -171,11 +171,9 @@ function processChildContext(fiber : Fiber, parentContext : Object, isReconcilin
171171

172172
let childContext;
173173
if (__DEV__) {
174-
ReactDebugLifeCycle.current = fiber;
175-
ReactDebugLifeCycle.phase = 'getChildContext';
174+
ReactDebugCurrentFiber.phase = 'getChildContext';
176175
childContext = instance.getChildContext();
177-
ReactDebugLifeCycle.current = null;
178-
ReactDebugLifeCycle.phase = null;
176+
ReactDebugCurrentFiber.phase = null;
179177
} else {
180178
childContext = instance.getChildContext();
181179
}

src/renderers/shared/fiber/ReactFiberReconciler.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ var ReactFiberScheduler = require('ReactFiberScheduler');
3232
if (__DEV__) {
3333
var warning = require('warning');
3434
var ReactFiberInstrumentation = require('ReactFiberInstrumentation');
35-
var warning = require('warning');
36-
var ReactDebugLifeCycle = require('ReactDebugLifeCycle');
35+
var ReactDebugCurrentFiber = require('ReactDebugCurrentFiber');
3736
var { getComponentName } = require('ReactFiberTreeReflection');
3837
}
3938

@@ -148,14 +147,14 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
148147

149148
function scheduleTopLevelUpdate(current : Fiber, element : ReactNodeList, callback : ?Function) {
150149
if (__DEV__) {
151-
if (ReactDebugLifeCycle.current !== null) {
150+
if (ReactDebugCurrentFiber.current !== null) {
152151
warning(
153-
ReactDebugLifeCycle.phase !== 'render',
152+
ReactDebugCurrentFiber.phase !== 'render',
154153
'Render methods should be a pure function of props and state; ' +
155154
'triggering nested component updates from render is not allowed. ' +
156155
'If necessary, trigger nested updates in componentDidUpdate.\n\n' +
157156
'Check the render method of %s.',
158-
getComponentName(ReactDebugLifeCycle.current)
157+
getComponentName(ReactDebugCurrentFiber.current)
159158
);
160159
}
161160
}

src/renderers/shared/fiber/ReactFiberScheduler.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ if (__DEV__) {
9090
var warning = require('warning');
9191
var ReactFiberInstrumentation = require('ReactFiberInstrumentation');
9292
var ReactDebugCurrentFiber = require('ReactDebugCurrentFiber');
93-
var ReactDebugLifeCycle = require('ReactDebugLifeCycle');
9493

9594
var warnAboutUpdateOnUnmounted = function(instance : ReactClass<any>) {
9695
const ctor = instance.constructor;
@@ -105,7 +104,7 @@ if (__DEV__) {
105104
};
106105

107106
var warnAboutInvalidUpdates = function(instance : ReactClass<any>) {
108-
switch (ReactDebugLifeCycle.phase) {
107+
switch (ReactDebugCurrentFiber.phase) {
109108
case 'getChildContext':
110109
warning(
111110
false,
@@ -880,8 +879,7 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(config : HostConfig<T, P,
880879
ReactCurrentOwner.current = null;
881880
if (__DEV__) {
882881
ReactDebugCurrentFiber.current = null;
883-
ReactDebugLifeCycle.current = null;
884-
ReactDebugLifeCycle.phase = null;
882+
ReactDebugCurrentFiber.phase = null;
885883
}
886884
// It is no longer valid because this unit of work failed.
887885
nextUnitOfWork = null;

src/renderers/shared/fiber/isomorphic/ReactDebugLifeCycle.js

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)