Skip to content

Commit bda6a9b

Browse files
committed
refactor(getComponentName): Use element types instead of fiber types
1 parent 843b50c commit bda6a9b

20 files changed

Lines changed: 63 additions & 60 deletions

packages/react-dom/src/client/ReactDOMLegacy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ export function findDOMNode(
235235
'never access something that requires stale data from the previous ' +
236236
'render, such as refs. Move this logic to componentDidMount and ' +
237237
'componentDidUpdate instead.',
238-
getComponentName(owner.type) || 'A component',
238+
getComponentName(owner.elementType) || 'A component',
239239
);
240240
}
241241
owner.stateNode._warnedAboutRefsInRender = true;

packages/react-dom/src/server/ReactPartialRenderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1310,7 +1310,7 @@ class ReactDOMServerRenderer {
13101310
"it's defined in, or you might have mixed up default and " +
13111311
'named imports.';
13121312
}
1313-
const ownerName = owner ? getComponentName(owner) : null;
1313+
const ownerName = owner ? getComponentName(owner.elementType) : null;
13141314
if (ownerName) {
13151315
info += '\n\nCheck the render method of `' + ownerName + '`.';
13161316
}

packages/react-native-renderer/src/ReactFabric.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function findHostInstance_DEPRECATED(
5757
'never access something that requires stale data from the previous ' +
5858
'render, such as refs. Move this logic to componentDidMount and ' +
5959
'componentDidUpdate instead.',
60-
getComponentName(owner.type) || 'A component',
60+
getComponentName(owner.elementType) || 'A component',
6161
);
6262
}
6363

@@ -104,7 +104,7 @@ function findNodeHandle(componentOrHandle: any): ?number {
104104
'never access something that requires stale data from the previous ' +
105105
'render, such as refs. Move this logic to componentDidMount and ' +
106106
'componentDidUpdate instead.',
107-
getComponentName(owner.type) || 'A component',
107+
getComponentName(owner.elementType) || 'A component',
108108
);
109109
}
110110

packages/react-native-renderer/src/ReactNativeFiberInspector.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ if (__DEV__) {
8181

8282
const createHierarchy = function(fiberHierarchy) {
8383
return fiberHierarchy.map(fiber => ({
84-
name: getComponentName(fiber.type),
84+
name: getComponentName(fiber.elementType),
8585
getInspectorData: findNodeHandle => {
8686
return {
8787
props: getHostProps(fiber),

packages/react-native-renderer/src/ReactNativeRenderer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function findHostInstance_DEPRECATED(
5959
'never access something that requires stale data from the previous ' +
6060
'render, such as refs. Move this logic to componentDidMount and ' +
6161
'componentDidUpdate instead.',
62-
getComponentName(owner.type) || 'A component',
62+
getComponentName(owner.elementType) || 'A component',
6363
);
6464
}
6565

@@ -106,7 +106,7 @@ function findNodeHandle(componentOrHandle: any): ?number {
106106
'never access something that requires stale data from the previous ' +
107107
'render, such as refs. Move this logic to componentDidMount and ' +
108108
'componentDidUpdate instead.',
109-
getComponentName(owner.type) || 'A component',
109+
getComponentName(owner.elementType) || 'A component',
110110
);
111111
}
112112

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ function coerceRef(
128128
element._owner.stateNode !== element._self
129129
)
130130
) {
131-
const componentName = getComponentName(returnFiber.type) || 'Component';
131+
const componentName =
132+
getComponentName(returnFiber.elementType) || 'Component';
132133
if (!didWarnAboutStringRefs[componentName]) {
133134
if (warnAboutStringRefs) {
134135
console.error(

packages/react-reconciler/src/ReactCurrentFiber.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function getCurrentFiberOwnerNameInDevOrNull(): string | null {
2525
}
2626
const owner = current._debugOwner;
2727
if (owner !== null && typeof owner !== 'undefined') {
28-
return getComponentName(owner.type);
28+
return getComponentName(owner.elementType);
2929
}
3030
}
3131
return null;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ export function createFiberFromTypeAndProps(
565565
"it's defined in, or you might have mixed up default and " +
566566
'named imports.';
567567
}
568-
const ownerName = owner ? getComponentName(owner.type) : null;
568+
const ownerName = owner ? getComponentName(owner.elementType) : null;
569569
if (ownerName) {
570570
info += '\n\nCheck the render method of `' + ownerName + '`.';
571571
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ function updateClassComponent(
878878
console.error(
879879
'It looks like %s is reassigning its own `this.props` while rendering. ' +
880880
'This is not supported and can lead to confusing bugs.',
881-
getComponentName(workInProgress.type) || 'a component',
881+
getComponentName(workInProgress.elementType) || 'a component',
882882
);
883883
}
884884
didWarnAboutReassigningProps = true;
@@ -3401,7 +3401,7 @@ function beginWork(
34013401
outerPropTypes,
34023402
resolvedProps, // Resolved for outer only
34033403
'prop',
3404-
getComponentName(type),
3404+
getComponentName(workInProgress.elementType),
34053405
);
34063406
}
34073407
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ function callComponentWillMount(workInProgress, instance) {
734734
'%s.componentWillMount(): Assigning directly to this.state is ' +
735735
"deprecated (except inside a component's " +
736736
'constructor). Use setState instead.',
737-
getComponentName(workInProgress.type) || 'Component',
737+
getComponentName(workInProgress.elementType) || 'Component',
738738
);
739739
}
740740
classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
@@ -758,7 +758,7 @@ function callComponentWillReceiveProps(
758758
if (instance.state !== oldState) {
759759
if (__DEV__) {
760760
const componentName =
761-
getComponentName(workInProgress.type) || 'Component';
761+
getComponentName(workInProgress.elementType) || 'Component';
762762
if (!didWarnAboutStateAssignmentForComponent.has(componentName)) {
763763
didWarnAboutStateAssignmentForComponent.add(componentName);
764764
console.error(

0 commit comments

Comments
 (0)