@@ -14,7 +14,7 @@ import type {ReactProvider, ReactContext} from 'shared/ReactTypes';
1414
1515import * as React from 'react' ;
1616import invariant from 'shared/invariant' ;
17- import getComponentName from 'shared/getComponentName ' ;
17+ import getComponentNameFromType from 'shared/getComponentNameFromType ' ;
1818import { describeUnknownElementTypeFrameInDEV } from 'shared/ReactComponentStackFrame' ;
1919import ReactSharedInternals from 'shared/ReactSharedInternals' ;
2020import {
@@ -259,7 +259,7 @@ function warnNoop(
259259 if ( __DEV__ ) {
260260 const constructor = publicInstance . constructor ;
261261 const componentName =
262- ( constructor && getComponentName ( constructor ) ) || 'ReactClass' ;
262+ ( constructor && getComponentNameFromType ( constructor ) ) || 'ReactClass' ;
263263 const warningKey = componentName + '.' + callerName ;
264264 if ( didWarnAboutNoopUpdateForComponent [ warningKey ] ) {
265265 return ;
@@ -404,7 +404,7 @@ function validateRenderResult(child, type) {
404404 '%s(...): Nothing was returned from render. This usually means a ' +
405405 'return statement is missing. Or, to render nothing, ' +
406406 'return null.' ,
407- getComponentName ( type ) || 'Component' ,
407+ getComponentNameFromType ( type ) || 'Component' ,
408408 ) ;
409409 }
410410}
@@ -467,7 +467,8 @@ function resolve(
467467 if ( typeof Component . getDerivedStateFromProps === 'function' ) {
468468 if ( __DEV__ ) {
469469 if ( inst . state === null || inst . state === undefined ) {
470- const componentName = getComponentName ( Component ) || 'Unknown' ;
470+ const componentName =
471+ getComponentNameFromType ( Component ) || 'Unknown' ;
471472 if ( ! didWarnAboutUninitializedState [ componentName ] ) {
472473 console . error (
473474 '`%s` uses `getDerivedStateFromProps` but its initial state is ' +
@@ -491,7 +492,8 @@ function resolve(
491492
492493 if ( __DEV__ ) {
493494 if ( partialState === undefined ) {
494- const componentName = getComponentName ( Component ) || 'Unknown' ;
495+ const componentName =
496+ getComponentNameFromType ( Component ) || 'Unknown' ;
495497 if ( ! didWarnAboutUndefinedDerivedState [ componentName ] ) {
496498 console . error (
497499 '%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' +
@@ -513,7 +515,8 @@ function resolve(
513515 Component . prototype &&
514516 typeof Component . prototype . render === 'function'
515517 ) {
516- const componentName = getComponentName ( Component ) || 'Unknown' ;
518+ const componentName =
519+ getComponentNameFromType ( Component ) || 'Unknown' ;
517520
518521 if ( ! didWarnAboutBadClass [ componentName ] ) {
519522 console . error (
@@ -535,7 +538,8 @@ function resolve(
535538 // Support for module components is deprecated and is removed behind a flag.
536539 // Whether or not it would crash later, we want to show a good message in DEV first.
537540 if ( inst != null && inst . render != null ) {
538- const componentName = getComponentName ( Component ) || 'Unknown' ;
541+ const componentName =
542+ getComponentNameFromType ( Component ) || 'Unknown' ;
539543 if ( ! didWarnAboutModulePatternComponent [ componentName ] ) {
540544 console . error (
541545 'The <%s /> component appears to be a function component that returns a class instance. ' +
@@ -583,7 +587,8 @@ function resolve(
583587 warnAboutDeprecatedLifecycles &&
584588 inst . componentWillMount . __suppressDeprecationWarning !== true
585589 ) {
586- const componentName = getComponentName ( Component ) || 'Unknown' ;
590+ const componentName =
591+ getComponentNameFromType ( Component ) || 'Unknown' ;
587592
588593 if ( ! didWarnAboutDeprecatedWillMount [ componentName ] ) {
589594 console . warn (
@@ -665,7 +670,7 @@ function resolve(
665670 console . error (
666671 '%s uses the legacy childContextTypes API which is no longer supported. ' +
667672 'Use React.createContext() instead.' ,
668- getComponentName ( Component ) || 'Unknown' ,
673+ getComponentNameFromType ( Component ) || 'Unknown' ,
669674 ) ;
670675 }
671676 }
@@ -678,7 +683,7 @@ function resolve(
678683 invariant (
679684 contextKey in childContextTypes ,
680685 '%s.getChildContext(): key "%s" is not defined in childContextTypes.' ,
681- getComponentName ( Component ) || 'Unknown' ,
686+ getComponentNameFromType ( Component ) || 'Unknown' ,
682687 contextKey ,
683688 ) ;
684689 }
@@ -687,7 +692,7 @@ function resolve(
687692 console . error (
688693 '%s.getChildContext(): childContextTypes must be defined in order to ' +
689694 'use getChildContext().' ,
690- getComponentName ( Component ) || 'Unknown' ,
695+ getComponentNameFromType ( Component ) || 'Unknown' ,
691696 ) ;
692697 }
693698 }
@@ -1298,7 +1303,7 @@ class ReactDOMServerRenderer {
12981303 "it's defined in, or you might have mixed up default and " +
12991304 'named imports.' ;
13001305 }
1301- const ownerName = owner ? getComponentName ( owner ) : null ;
1306+ const ownerName = owner ? getComponentNameFromType ( owner ) : null ;
13021307 if ( ownerName ) {
13031308 info += '\n\nCheck the render method of `' + ownerName + '`.' ;
13041309 }
0 commit comments