Skip to content

Commit

Permalink
Removed _debugID field from Fiber - Issue facebook#21558 (facebook#21570
Browse files Browse the repository at this point in the history
)

* Removed _debugID field from Fiber
* Update ReactFunctionComponent-test.js

Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
  • Loading branch information
2 people authored and koto committed Jun 15, 2021
1 parent 0210123 commit 70b2996
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 17 deletions.
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

0 comments on commit 70b2996

Please sign in to comment.