Skip to content

Removed _debugID field from Fiber - Issue #21558 #21570

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,8 @@ describe('ReactFunctionComponent', () => {
}).toErrorDev('Warning: Function components cannot be given refs.');
// Should be deduped (same internal instance, no additional warnings)
instance2.forceUpdate();
// Could not be deduped (different internal instance):
expect(() =>
ReactTestUtils.renderIntoDocument(<AnonymousParentNotUsingJSX />),
).toErrorDev('Warning: Function components cannot be given refs.');
// Could not be differentiated (since owner is anonymous and no source location)
ReactTestUtils.renderIntoDocument(<AnonymousParentNotUsingJSX />);

// When owner doesn't use JSX, but is named, we warn once per owner name
class NamedParentNotUsingJSX extends React.Component {
Expand Down
8 changes: 3 additions & 5 deletions packages/react-reconciler/src/ReactFiber.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ if (__DEV__) {
}
}

let debugCounter = 1;

function FiberNode(
tag: WorkTag,
pendingProps: mixed,
Expand Down Expand Up @@ -178,7 +176,7 @@ function FiberNode(

if (__DEV__) {
// This isn't directly used but is handy for debugging internals:
this._debugID = debugCounter++;

this._debugSource = null;
this._debugOwner = null;
this._debugNeedsRemount = false;
Expand Down Expand Up @@ -261,7 +259,7 @@ export function createWorkInProgress(current: Fiber, pendingProps: any): Fiber {

if (__DEV__) {
// DEV-only fields
workInProgress._debugID = current._debugID;

workInProgress._debugSource = current._debugSource;
workInProgress._debugOwner = current._debugOwner;
workInProgress._debugHookTypes = current._debugHookTypes;
Expand Down Expand Up @@ -809,7 +807,7 @@ export function assignFiberPropertiesInDEV(
target.selfBaseDuration = source.selfBaseDuration;
target.treeBaseDuration = source.treeBaseDuration;
}
target._debugID = source._debugID;

target._debugSource = source._debugSource;
target._debugOwner = source._debugOwner;
target._debugNeedsRemount = source._debugNeedsRemount;
Expand Down
8 changes: 3 additions & 5 deletions packages/react-reconciler/src/ReactFiber.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ if (__DEV__) {
}
}

let debugCounter = 1;

function FiberNode(
tag: WorkTag,
pendingProps: mixed,
Expand Down Expand Up @@ -178,7 +176,7 @@ function FiberNode(

if (__DEV__) {
// This isn't directly used but is handy for debugging internals:
this._debugID = debugCounter++;

this._debugSource = null;
this._debugOwner = null;
this._debugNeedsRemount = false;
Expand Down Expand Up @@ -261,7 +259,7 @@ export function createWorkInProgress(current: Fiber, pendingProps: any): Fiber {

if (__DEV__) {
// DEV-only fields
workInProgress._debugID = current._debugID;

workInProgress._debugSource = current._debugSource;
workInProgress._debugOwner = current._debugOwner;
workInProgress._debugHookTypes = current._debugHookTypes;
Expand Down Expand Up @@ -809,7 +807,7 @@ export function assignFiberPropertiesInDEV(
target.selfBaseDuration = source.selfBaseDuration;
target.treeBaseDuration = source.treeBaseDuration;
}
target._debugID = source._debugID;

target._debugSource = source._debugSource;
target._debugOwner = source._debugOwner;
target._debugNeedsRemount = source._debugNeedsRemount;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/ReactFiberBeginWork.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -1653,7 +1653,7 @@ function validateFunctionComponentInDev(workInProgress: Fiber, Component: any) {
info += '\n\nCheck the render method of `' + ownerName + '`.';
}

let warningKey = ownerName || workInProgress._debugID || '';
let warningKey = ownerName || '';
const debugSource = workInProgress._debugSource;
if (debugSource) {
warningKey = debugSource.fileName + ':' + debugSource.lineNumber;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/ReactFiberBeginWork.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -1653,7 +1653,7 @@ function validateFunctionComponentInDev(workInProgress: Fiber, Component: any) {
info += '\n\nCheck the render method of `' + ownerName + '`.';
}

let warningKey = ownerName || workInProgress._debugID || '';
let warningKey = ownerName || '';
const debugSource = workInProgress._debugSource;
if (debugSource) {
warningKey = debugSource.fileName + ':' + debugSource.lineNumber;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/ReactInternalTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export type Fiber = {|
// workInProgress : Fiber -> alternate The alternate used for reuse happens
// to be the same as work in progress.
// __DEV__ only
_debugID?: number,

_debugSource?: Source | null,
_debugOwner?: Fiber | null,
_debugIsCurrentlyTiming?: boolean,
Expand Down