Skip to content

Commit 0d493dc

Browse files
Pulkit3234bvaughn
andauthored
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>
1 parent bb1c821 commit 0d493dc

File tree

6 files changed

+11
-17
lines changed

6 files changed

+11
-17
lines changed

packages/react-dom/src/__tests__/ReactFunctionComponent-test.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,8 @@ describe('ReactFunctionComponent', () => {
284284
}).toErrorDev('Warning: Function components cannot be given refs.');
285285
// Should be deduped (same internal instance, no additional warnings)
286286
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 />);
291289

292290
// When owner doesn't use JSX, but is named, we warn once per owner name
293291
class NamedParentNotUsingJSX extends React.Component {

packages/react-reconciler/src/ReactFiber.new.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ if (__DEV__) {
108108
}
109109
}
110110

111-
let debugCounter = 1;
112-
113111
function FiberNode(
114112
tag: WorkTag,
115113
pendingProps: mixed,
@@ -178,7 +176,7 @@ function FiberNode(
178176

179177
if (__DEV__) {
180178
// This isn't directly used but is handy for debugging internals:
181-
this._debugID = debugCounter++;
179+
182180
this._debugSource = null;
183181
this._debugOwner = null;
184182
this._debugNeedsRemount = false;
@@ -261,7 +259,7 @@ export function createWorkInProgress(current: Fiber, pendingProps: any): Fiber {
261259

262260
if (__DEV__) {
263261
// DEV-only fields
264-
workInProgress._debugID = current._debugID;
262+
265263
workInProgress._debugSource = current._debugSource;
266264
workInProgress._debugOwner = current._debugOwner;
267265
workInProgress._debugHookTypes = current._debugHookTypes;
@@ -809,7 +807,7 @@ export function assignFiberPropertiesInDEV(
809807
target.selfBaseDuration = source.selfBaseDuration;
810808
target.treeBaseDuration = source.treeBaseDuration;
811809
}
812-
target._debugID = source._debugID;
810+
813811
target._debugSource = source._debugSource;
814812
target._debugOwner = source._debugOwner;
815813
target._debugNeedsRemount = source._debugNeedsRemount;

packages/react-reconciler/src/ReactFiber.old.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ if (__DEV__) {
108108
}
109109
}
110110

111-
let debugCounter = 1;
112-
113111
function FiberNode(
114112
tag: WorkTag,
115113
pendingProps: mixed,
@@ -178,7 +176,7 @@ function FiberNode(
178176

179177
if (__DEV__) {
180178
// This isn't directly used but is handy for debugging internals:
181-
this._debugID = debugCounter++;
179+
182180
this._debugSource = null;
183181
this._debugOwner = null;
184182
this._debugNeedsRemount = false;
@@ -261,7 +259,7 @@ export function createWorkInProgress(current: Fiber, pendingProps: any): Fiber {
261259

262260
if (__DEV__) {
263261
// DEV-only fields
264-
workInProgress._debugID = current._debugID;
262+
265263
workInProgress._debugSource = current._debugSource;
266264
workInProgress._debugOwner = current._debugOwner;
267265
workInProgress._debugHookTypes = current._debugHookTypes;
@@ -809,7 +807,7 @@ export function assignFiberPropertiesInDEV(
809807
target.selfBaseDuration = source.selfBaseDuration;
810808
target.treeBaseDuration = source.treeBaseDuration;
811809
}
812-
target._debugID = source._debugID;
810+
813811
target._debugSource = source._debugSource;
814812
target._debugOwner = source._debugOwner;
815813
target._debugNeedsRemount = source._debugNeedsRemount;

packages/react-reconciler/src/ReactFiberBeginWork.new.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1653,7 +1653,7 @@ function validateFunctionComponentInDev(workInProgress: Fiber, Component: any) {
16531653
info += '\n\nCheck the render method of `' + ownerName + '`.';
16541654
}
16551655

1656-
let warningKey = ownerName || workInProgress._debugID || '';
1656+
let warningKey = ownerName || '';
16571657
const debugSource = workInProgress._debugSource;
16581658
if (debugSource) {
16591659
warningKey = debugSource.fileName + ':' + debugSource.lineNumber;

packages/react-reconciler/src/ReactFiberBeginWork.old.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1653,7 +1653,7 @@ function validateFunctionComponentInDev(workInProgress: Fiber, Component: any) {
16531653
info += '\n\nCheck the render method of `' + ownerName + '`.';
16541654
}
16551655

1656-
let warningKey = ownerName || workInProgress._debugID || '';
1656+
let warningKey = ownerName || '';
16571657
const debugSource = workInProgress._debugSource;
16581658
if (debugSource) {
16591659
warningKey = debugSource.fileName + ':' + debugSource.lineNumber;

packages/react-reconciler/src/ReactInternalTypes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ export type Fiber = {|
178178
// workInProgress : Fiber -> alternate The alternate used for reuse happens
179179
// to be the same as work in progress.
180180
// __DEV__ only
181-
_debugID?: number,
181+
182182
_debugSource?: Source | null,
183183
_debugOwner?: Fiber | null,
184184
_debugIsCurrentlyTiming?: boolean,

0 commit comments

Comments
 (0)