Removed _debugID field from Fiber - Issue #21558 (#21570)
* Removed _debugID field from Fiber * Update ReactFunctionComponent-test.js Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
Pulkit Sharma committed
May 27, 2021 at 02:23 UTC
0d493dcda96fc86242cf9a05a44130978a56fbdd
6 files changed
+11
-17
packages/react-dom/src/__tests__/ReactFunctionComponent-test.js
+2
-4
@@ -284,10 +284,8 @@ describe('ReactFunctionComponent', () => {
284
}).toErrorDev('Warning: Function components cannot be given refs.');
285
// Should be deduped (same internal instance, no additional warnings)
286
instance2.forceUpdate();
287
- // Could not be deduped (different internal instance):
288
- expect(() =>
289
- ReactTestUtils.renderIntoDocument(<AnonymousParentNotUsingJSX />),
290
- ).toErrorDev('Warning: Function components cannot be given refs.');
287
+ // Could not be differentiated (since owner is anonymous and no source location)
288
+ ReactTestUtils.renderIntoDocument(<AnonymousParentNotUsingJSX />);
289
290
// When owner doesn't use JSX, but is named, we warn once per owner name
291
class NamedParentNotUsingJSX extends React.Component {
packages/react-reconciler/src/ReactFiber.new.js
+3
-5
@@ -108,8 +108,6 @@ if (__DEV__) {
108
}
109
}
110
111
-let debugCounter = 1;
112
-
111
function FiberNode(
112
tag: WorkTag,
113
pendingProps: mixed,
@@ -178,7 +176,7 @@ function FiberNode(
176
177
if (__DEV__) {
178
// This isn't directly used but is handy for debugging internals:
181
- this._debugID = debugCounter++;
179
+
180
this._debugSource = null;
181
this._debugOwner = null;
182
this._debugNeedsRemount = false;
@@ -261,7 +259,7 @@ export function createWorkInProgress(current: Fiber, pendingProps: any): Fiber {
259
260
if (__DEV__) {
261
// DEV-only fields
264
- workInProgress._debugID = current._debugID;
262
+
263
workInProgress._debugSource = current._debugSource;
264
workInProgress._debugOwner = current._debugOwner;
265
workInProgress._debugHookTypes = current._debugHookTypes;
@@ -809,7 +807,7 @@ export function assignFiberPropertiesInDEV(
807
target.selfBaseDuration = source.selfBaseDuration;
808
target.treeBaseDuration = source.treeBaseDuration;
809
}
812
- target._debugID = source._debugID;
810
+
811
target._debugSource = source._debugSource;
812
target._debugOwner = source._debugOwner;
813
target._debugNeedsRemount = source._debugNeedsRemount;
packages/react-reconciler/src/ReactFiber.old.js
+3
-5
@@ -108,8 +108,6 @@ if (__DEV__) {
108
}
109
}
110
111
-let debugCounter = 1;
112
-
111
function FiberNode(
112
tag: WorkTag,
113
pendingProps: mixed,
@@ -178,7 +176,7 @@ function FiberNode(
176
177
if (__DEV__) {
178
// This isn't directly used but is handy for debugging internals:
181
- this._debugID = debugCounter++;
179
+
180
this._debugSource = null;
181
this._debugOwner = null;
182
this._debugNeedsRemount = false;
@@ -261,7 +259,7 @@ export function createWorkInProgress(current: Fiber, pendingProps: any): Fiber {
259
260
if (__DEV__) {
261
// DEV-only fields
264
- workInProgress._debugID = current._debugID;
262
+
263
workInProgress._debugSource = current._debugSource;
264
workInProgress._debugOwner = current._debugOwner;
265
workInProgress._debugHookTypes = current._debugHookTypes;
@@ -809,7 +807,7 @@ export function assignFiberPropertiesInDEV(
807
target.selfBaseDuration = source.selfBaseDuration;
808
target.treeBaseDuration = source.treeBaseDuration;
809
}
812
- target._debugID = source._debugID;
810
+
811
target._debugSource = source._debugSource;
812
target._debugOwner = source._debugOwner;
813
target._debugNeedsRemount = source._debugNeedsRemount;
packages/react-reconciler/src/ReactFiberBeginWork.new.js
+1
-1
@@ -1653,7 +1653,7 @@ function validateFunctionComponentInDev(workInProgress: Fiber, Component: any) {
1653
info += '\n\nCheck the render method of `' + ownerName + '`.';
1654
}
1655
1656
- let warningKey = ownerName || workInProgress._debugID || '';
1656
+ let warningKey = ownerName || '';
1657
const debugSource = workInProgress._debugSource;
1658
if (debugSource) {
1659
warningKey = debugSource.fileName + ':' + debugSource.lineNumber;
packages/react-reconciler/src/ReactFiberBeginWork.old.js
+1
-1
@@ -1653,7 +1653,7 @@ function validateFunctionComponentInDev(workInProgress: Fiber, Component: any) {
1653
info += '\n\nCheck the render method of `' + ownerName + '`.';
1654
}
1655
1656
- let warningKey = ownerName || workInProgress._debugID || '';
1656
+ let warningKey = ownerName || '';
1657
const debugSource = workInProgress._debugSource;
1658
if (debugSource) {
1659
warningKey = debugSource.fileName + ':' + debugSource.lineNumber;
packages/react-reconciler/src/ReactInternalTypes.js
+1
-1
@@ -178,7 +178,7 @@ export type Fiber = {|
178
// workInProgress : Fiber -> alternate The alternate used for reuse happens
179
// to be the same as work in progress.
180
// __DEV__ only
181
- _debugID?: number,
181
+
182
_debugSource?: Source | null,
183
_debugOwner?: Fiber | null,
184
_debugIsCurrentlyTiming?: boolean,