GeezerVison is showing github.com — Split getComponentName into getComponentNameFromFiber and getComponen… · react/react@7df6572
File treeExpand file treeCollapse file tree Open diff view settings react-native-renderer/src
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/client/ReactDOMLegacy.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -32,7 +32,7 @@ import { | 32 | 32 | findHostInstance, | 33 | 33 | findHostInstanceWithWarning, | 34 | 34 | } from 'react-reconciler/src/ReactFiberReconciler'; | 35 | | -import getComponentName from 'shared/getComponentName'; | | 35 | +import getComponentNameFromType from 'shared/getComponentNameFromType'; | 36 | 36 | import invariant from 'shared/invariant'; | 37 | 37 | import ReactSharedInternals from 'shared/ReactSharedInternals'; | 38 | 38 | import {has as hasInstance} from 'shared/ReactInstanceMap'; | @@ -235,7 +235,7 @@ export function findDOMNode( | 235 | 235 | 'never access something that requires stale data from the previous ' + | 236 | 236 | 'render, such as refs. Move this logic to componentDidMount and ' + | 237 | 237 | 'componentDidUpdate instead.', | 238 | | - getComponentName(owner.type) || 'A component', | | 238 | + getComponentNameFromType(owner.type) || 'A component', | 239 | 239 | ); | 240 | 240 | } | 241 | 241 | owner.stateNode._warnedAboutRefsInRender = true; | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/server/ReactPartialRenderer.js +17-12Lines changed: 17 additions & 12 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -14,7 +14,7 @@ import type {ReactProvider, ReactContext} from 'shared/ReactTypes'; | 14 | 14 |
| 15 | 15 | import * as React from 'react'; | 16 | 16 | import invariant from 'shared/invariant'; | 17 | | -import getComponentName from 'shared/getComponentName'; | | 17 | +import getComponentNameFromType from 'shared/getComponentNameFromType'; | 18 | 18 | import {describeUnknownElementTypeFrameInDEV} from 'shared/ReactComponentStackFrame'; | 19 | 19 | import ReactSharedInternals from 'shared/ReactSharedInternals'; | 20 | 20 | import { | @@ -259,7 +259,7 @@ function warnNoop( | 259 | 259 | if (__DEV__) { | 260 | 260 | const constructor = publicInstance.constructor; | 261 | 261 | const componentName = | 262 | | - (constructor && getComponentName(constructor)) || 'ReactClass'; | | 262 | + (constructor && getComponentNameFromType(constructor)) || 'ReactClass'; | 263 | 263 | const warningKey = componentName + '.' + callerName; | 264 | 264 | if (didWarnAboutNoopUpdateForComponent[warningKey]) { | 265 | 265 | return; | @@ -404,7 +404,7 @@ function validateRenderResult(child, type) { | 404 | 404 | '%s(...): Nothing was returned from render. This usually means a ' + | 405 | 405 | 'return statement is missing. Or, to render nothing, ' + | 406 | 406 | 'return null.', | 407 | | - getComponentName(type) || 'Component', | | 407 | + getComponentNameFromType(type) || 'Component', | 408 | 408 | ); | 409 | 409 | } | 410 | 410 | } | @@ -467,7 +467,8 @@ function resolve( | 467 | 467 | if (typeof Component.getDerivedStateFromProps === 'function') { | 468 | 468 | if (__DEV__) { | 469 | 469 | if (inst.state === null || inst.state === undefined) { | 470 | | - const componentName = getComponentName(Component) || 'Unknown'; | | 470 | + const componentName = | | 471 | + getComponentNameFromType(Component) || 'Unknown'; | 471 | 472 | if (!didWarnAboutUninitializedState[componentName]) { | 472 | 473 | console.error( | 473 | 474 | '`%s` uses `getDerivedStateFromProps` but its initial state is ' + | @@ -491,7 +492,8 @@ function resolve( | 491 | 492 |
| 492 | 493 | if (__DEV__) { | 493 | 494 | if (partialState === undefined) { | 494 | | - const componentName = getComponentName(Component) || 'Unknown'; | | 495 | + const componentName = | | 496 | + getComponentNameFromType(Component) || 'Unknown'; | 495 | 497 | if (!didWarnAboutUndefinedDerivedState[componentName]) { | 496 | 498 | console.error( | 497 | 499 | '%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + | @@ -513,7 +515,8 @@ function resolve( | 513 | 515 | Component.prototype && | 514 | 516 | typeof Component.prototype.render === 'function' | 515 | 517 | ) { | 516 | | - const componentName = getComponentName(Component) || 'Unknown'; | | 518 | + const componentName = | | 519 | + getComponentNameFromType(Component) || 'Unknown'; | 517 | 520 |
| 518 | 521 | if (!didWarnAboutBadClass[componentName]) { | 519 | 522 | console.error( | @@ -535,7 +538,8 @@ function resolve( | 535 | 538 | // Support for module components is deprecated and is removed behind a flag. | 536 | 539 | // Whether or not it would crash later, we want to show a good message in DEV first. | 537 | 540 | if (inst != null && inst.render != null) { | 538 | | - const componentName = getComponentName(Component) || 'Unknown'; | | 541 | + const componentName = | | 542 | + getComponentNameFromType(Component) || 'Unknown'; | 539 | 543 | if (!didWarnAboutModulePatternComponent[componentName]) { | 540 | 544 | console.error( | 541 | 545 | 'The <%s /> component appears to be a function component that returns a class instance. ' + | @@ -583,7 +587,8 @@ function resolve( | 583 | 587 | warnAboutDeprecatedLifecycles && | 584 | 588 | inst.componentWillMount.__suppressDeprecationWarning !== true | 585 | 589 | ) { | 586 | | - const componentName = getComponentName(Component) || 'Unknown'; | | 590 | + const componentName = | | 591 | + getComponentNameFromType(Component) || 'Unknown'; | 587 | 592 |
| 588 | 593 | if (!didWarnAboutDeprecatedWillMount[componentName]) { | 589 | 594 | console.warn( | @@ -665,7 +670,7 @@ function resolve( | 665 | 670 | console.error( | 666 | 671 | '%s uses the legacy childContextTypes API which is no longer supported. ' + | 667 | 672 | 'Use React.createContext() instead.', | 668 | | - getComponentName(Component) || 'Unknown', | | 673 | + getComponentNameFromType(Component) || 'Unknown', | 669 | 674 | ); | 670 | 675 | } | 671 | 676 | } | @@ -678,7 +683,7 @@ function resolve( | 678 | 683 | invariant( | 679 | 684 | contextKey in childContextTypes, | 680 | 685 | '%s.getChildContext(): key "%s" is not defined in childContextTypes.', | 681 | | - getComponentName(Component) || 'Unknown', | | 686 | + getComponentNameFromType(Component) || 'Unknown', | 682 | 687 | contextKey, | 683 | 688 | ); | 684 | 689 | } | @@ -687,7 +692,7 @@ function resolve( | 687 | 692 | console.error( | 688 | 693 | '%s.getChildContext(): childContextTypes must be defined in order to ' + | 689 | 694 | 'use getChildContext().', | 690 | | - getComponentName(Component) || 'Unknown', | | 695 | + getComponentNameFromType(Component) || 'Unknown', | 691 | 696 | ); | 692 | 697 | } | 693 | 698 | } | @@ -1298,7 +1303,7 @@ class ReactDOMServerRenderer { | 1298 | 1303 | "it's defined in, or you might have mixed up default and " + | 1299 | 1304 | 'named imports.'; | 1300 | 1305 | } | 1301 | | - const ownerName = owner ? getComponentName(owner) : null; | | 1306 | + const ownerName = owner ? getComponentNameFromType(owner) : null; | 1302 | 1307 | if (ownerName) { | 1303 | 1308 | info += '\n\nCheck the render method of `' + ownerName + '`.'; | 1304 | 1309 | } | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-dom/src/server/ReactPartialRendererContext.js +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -12,7 +12,7 @@ import type {ReactContext} from 'shared/ReactTypes'; | 12 | 12 |
| 13 | 13 | import {disableLegacyContext} from 'shared/ReactFeatureFlags'; | 14 | 14 | import {REACT_CONTEXT_TYPE, REACT_PROVIDER_TYPE} from 'shared/ReactSymbols'; | 15 | | -import getComponentName from 'shared/getComponentName'; | | 15 | +import getComponentNameFromType from 'shared/getComponentNameFromType'; | 16 | 16 | import checkPropTypes from 'shared/checkPropTypes'; | 17 | 17 |
| 18 | 18 | let didWarnAboutInvalidateContextType; | @@ -105,7 +105,7 @@ export function processContext( | 105 | 105 | console.error( | 106 | 106 | '%s defines an invalid contextType. ' + | 107 | 107 | 'contextType should point to the Context object returned by React.createContext().%s', | 108 | | - getComponentName(type) || 'Component', | | 108 | + getComponentNameFromType(type) || 'Component', | 109 | 109 | addendum, | 110 | 110 | ); | 111 | 111 | } | @@ -121,7 +121,7 @@ export function processContext( | 121 | 121 | console.error( | 122 | 122 | '%s uses the legacy contextTypes API which is no longer supported. ' + | 123 | 123 | 'Use React.createContext() with static contextType instead.', | 124 | | - getComponentName(type) || 'Unknown', | | 124 | + getComponentNameFromType(type) || 'Unknown', | 125 | 125 | ); | 126 | 126 | } | 127 | 127 | } | @@ -142,7 +142,7 @@ export function processContext( | 142 | 142 | console.error( | 143 | 143 | '%s uses the legacy contextTypes API which is no longer supported. ' + | 144 | 144 | 'Use React.createContext() with React.useContext() instead.', | 145 | | - getComponentName(type) || 'Unknown', | | 145 | + getComponentNameFromType(type) || 'Unknown', | 146 | 146 | ); | 147 | 147 | } | 148 | 148 | } | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-native-renderer/src/ReactFabric.js +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -43,7 +43,7 @@ import { | 43 | 43 | } from './ReactNativeFiberInspector'; | 44 | 44 | import {LegacyRoot} from 'react-reconciler/src/ReactRootTags'; | 45 | 45 | import ReactSharedInternals from 'shared/ReactSharedInternals'; | 46 | | -import getComponentName from 'shared/getComponentName'; | | 46 | +import getComponentNameFromType from 'shared/getComponentNameFromType'; | 47 | 47 |
| 48 | 48 | const ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; | 49 | 49 |
| @@ -60,7 +60,7 @@ function findHostInstance_DEPRECATED<TElementType: ElementType>( | 60 | 60 | 'never access something that requires stale data from the previous ' + | 61 | 61 | 'render, such as refs. Move this logic to componentDidMount and ' + | 62 | 62 | 'componentDidUpdate instead.', | 63 | | - getComponentName(owner.type) || 'A component', | | 63 | + getComponentNameFromType(owner.type) || 'A component', | 64 | 64 | ); | 65 | 65 | } | 66 | 66 |
| @@ -111,7 +111,7 @@ function findNodeHandle(componentOrHandle: any): ?number { | 111 | 111 | 'never access something that requires stale data from the previous ' + | 112 | 112 | 'render, such as refs. Move this logic to componentDidMount and ' + | 113 | 113 | 'componentDidUpdate instead.', | 114 | | - getComponentName(owner.type) || 'A component', | | 114 | + getComponentNameFromType(owner.type) || 'A component', | 115 | 115 | ); | 116 | 116 | } | 117 | 117 |
| |
Collapse file Copy file name to clipboardExpand all lines: packages/react-native-renderer/src/ReactNativeFiberInspector.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -14,7 +14,7 @@ import { | 14 | 14 | findCurrentHostFiber, | 15 | 15 | findCurrentFiberUsingSlowPath, | 16 | 16 | } from 'react-reconciler/src/ReactFiberTreeReflection'; | 17 | | -import getComponentName from 'shared/getComponentName'; | | 17 | +import getComponentNameFromType from 'shared/getComponentNameFromType'; | 18 | 18 | import {HostComponent} from 'react-reconciler/src/ReactWorkTags'; | 19 | 19 | import invariant from 'shared/invariant'; | 20 | 20 | // Module provided by RN: | @@ -81,7 +81,7 @@ if (__DEV__) { | 81 | 81 |
| 82 | 82 | const createHierarchy = function(fiberHierarchy) { | 83 | 83 | return fiberHierarchy.map(fiber => ({ | 84 | | - name: getComponentName(fiber.type), | | 84 | + name: getComponentNameFromType(fiber.type), | 85 | 85 | getInspectorData: findNodeHandle => { | 86 | 86 | return { | 87 | 87 | props: getHostProps(fiber), | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-native-renderer/src/ReactNativeRenderer.js +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -46,7 +46,7 @@ import { | 46 | 46 | } from './ReactNativeFiberInspector'; | 47 | 47 | import {LegacyRoot} from 'react-reconciler/src/ReactRootTags'; | 48 | 48 | import ReactSharedInternals from 'shared/ReactSharedInternals'; | 49 | | -import getComponentName from 'shared/getComponentName'; | | 49 | +import getComponentNameFromType from 'shared/getComponentNameFromType'; | 50 | 50 |
| 51 | 51 | const ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; | 52 | 52 |
| @@ -63,7 +63,7 @@ function findHostInstance_DEPRECATED( | 63 | 63 | 'never access something that requires stale data from the previous ' + | 64 | 64 | 'render, such as refs. Move this logic to componentDidMount and ' + | 65 | 65 | 'componentDidUpdate instead.', | 66 | | - getComponentName(owner.type) || 'A component', | | 66 | + getComponentNameFromType(owner.type) || 'A component', | 67 | 67 | ); | 68 | 68 | } | 69 | 69 |
| @@ -110,7 +110,7 @@ function findNodeHandle(componentOrHandle: any): ?number { | 110 | 110 | 'never access something that requires stale data from the previous ' + | 111 | 111 | 'render, such as refs. Move this logic to componentDidMount and ' + | 112 | 112 | 'componentDidUpdate instead.', | 113 | | - getComponentName(owner.type) || 'A component', | | 113 | + getComponentNameFromType(owner.type) || 'A component', | 114 | 114 | ); | 115 | 115 | } | 116 | 116 |
| |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactChildFiber.new.js +6-5Lines changed: 6 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -12,7 +12,7 @@ import type {ReactPortal} from 'shared/ReactTypes'; | 12 | 12 | import type {Fiber} from './ReactInternalTypes'; | 13 | 13 | import type {Lanes} from './ReactFiberLane.new'; | 14 | 14 |
| 15 | | -import getComponentName from 'shared/getComponentName'; | | 15 | +import getComponentNameFromFiber from 'react-reconciler/src/getComponentNameFromFiber'; | 16 | 16 | import {Placement, ChildDeletion} from './ReactFiberFlags'; | 17 | 17 | import { | 18 | 18 | getIteratorFn, | @@ -82,7 +82,7 @@ if (__DEV__) { | 82 | 82 | ); | 83 | 83 | child._store.validated = true; | 84 | 84 |
| 85 | | - const componentName = getComponentName(returnFiber.type) || 'Component'; | | 85 | + const componentName = getComponentNameFromFiber(returnFiber) || 'Component'; | 86 | 86 |
| 87 | 87 | if (ownerHasKeyUseWarning[componentName]) { | 88 | 88 | return; | @@ -124,7 +124,8 @@ function coerceRef( | 124 | 124 | element._owner.stateNode !== element._self | 125 | 125 | ) | 126 | 126 | ) { | 127 | | - const componentName = getComponentName(returnFiber.type) || 'Component'; | | 127 | + const componentName = | | 128 | + getComponentNameFromFiber(returnFiber) || 'Component'; | 128 | 129 | if (!didWarnAboutStringRefs[componentName]) { | 129 | 130 | if (warnAboutStringRefs) { | 130 | 131 | console.error( | @@ -232,7 +233,7 @@ function throwOnInvalidObjectType(returnFiber: Fiber, newChild: Object) { | 232 | 233 |
| 233 | 234 | function warnOnFunctionType(returnFiber: Fiber) { | 234 | 235 | if (__DEV__) { | 235 | | - const componentName = getComponentName(returnFiber.type) || 'Component'; | | 236 | + const componentName = getComponentNameFromFiber(returnFiber) || 'Component'; | 236 | 237 |
| 237 | 238 | if (ownerHasFunctionTypeWarning[componentName]) { | 238 | 239 | return; | @@ -1333,7 +1334,7 @@ function ChildReconciler(shouldTrackSideEffects) { | 1333 | 1334 | '%s(...): Nothing was returned from render. This usually means a ' + | 1334 | 1335 | 'return statement is missing. Or, to render nothing, ' + | 1335 | 1336 | 'return null.', | 1336 | | - getComponentName(returnFiber.type) || 'Component', | | 1337 | + getComponentNameFromFiber(returnFiber) || 'Component', | 1337 | 1338 | ); | 1338 | 1339 | } | 1339 | 1340 | } | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactChildFiber.old.js +6-5Lines changed: 6 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -12,7 +12,7 @@ import type {ReactPortal} from 'shared/ReactTypes'; | 12 | 12 | import type {Fiber} from './ReactInternalTypes'; | 13 | 13 | import type {Lanes} from './ReactFiberLane.old'; | 14 | 14 |
| 15 | | -import getComponentName from 'shared/getComponentName'; | | 15 | +import getComponentNameFromFiber from 'react-reconciler/src/getComponentNameFromFiber'; | 16 | 16 | import {Placement, ChildDeletion} from './ReactFiberFlags'; | 17 | 17 | import { | 18 | 18 | getIteratorFn, | @@ -82,7 +82,7 @@ if (__DEV__) { | 82 | 82 | ); | 83 | 83 | child._store.validated = true; | 84 | 84 |
| 85 | | - const componentName = getComponentName(returnFiber.type) || 'Component'; | | 85 | + const componentName = getComponentNameFromFiber(returnFiber) || 'Component'; | 86 | 86 |
| 87 | 87 | if (ownerHasKeyUseWarning[componentName]) { | 88 | 88 | return; | @@ -124,7 +124,8 @@ function coerceRef( | 124 | 124 | element._owner.stateNode !== element._self | 125 | 125 | ) | 126 | 126 | ) { | 127 | | - const componentName = getComponentName(returnFiber.type) || 'Component'; | | 127 | + const componentName = | | 128 | + getComponentNameFromFiber(returnFiber) || 'Component'; | 128 | 129 | if (!didWarnAboutStringRefs[componentName]) { | 129 | 130 | if (warnAboutStringRefs) { | 130 | 131 | console.error( | @@ -232,7 +233,7 @@ function throwOnInvalidObjectType(returnFiber: Fiber, newChild: Object) { | 232 | 233 |
| 233 | 234 | function warnOnFunctionType(returnFiber: Fiber) { | 234 | 235 | if (__DEV__) { | 235 | | - const componentName = getComponentName(returnFiber.type) || 'Component'; | | 236 | + const componentName = getComponentNameFromFiber(returnFiber) || 'Component'; | 236 | 237 |
| 237 | 238 | if (ownerHasFunctionTypeWarning[componentName]) { | 238 | 239 | return; | @@ -1333,7 +1334,7 @@ function ChildReconciler(shouldTrackSideEffects) { | 1333 | 1334 | '%s(...): Nothing was returned from render. This usually means a ' + | 1334 | 1335 | 'return statement is missing. Or, to render nothing, ' + | 1335 | 1336 | 'return null.', | 1336 | | - getComponentName(returnFiber.type) || 'Component', | | 1337 | + getComponentNameFromFiber(returnFiber) || 'Component', | 1337 | 1338 | ); | 1338 | 1339 | } | 1339 | 1340 | } | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactCurrentFiber.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -11,7 +11,7 @@ import type {Fiber} from './ReactInternalTypes'; | 11 | 11 |
| 12 | 12 | import ReactSharedInternals from 'shared/ReactSharedInternals'; | 13 | 13 | import {getStackByFiberInDevAndProd} from './ReactFiberComponentStack'; | 14 | | -import getComponentName from 'shared/getComponentName'; | | 14 | +import getComponentNameFromFiber from 'react-reconciler/src/getComponentNameFromFiber'; | 15 | 15 |
| 16 | 16 | const ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; | 17 | 17 |
| @@ -25,7 +25,7 @@ export function getCurrentFiberOwnerNameInDevOrNull(): string | null { | 25 | 25 | } | 26 | 26 | const owner = current._debugOwner; | 27 | 27 | if (owner !== null && typeof owner !== 'undefined') { | 28 | | - return getComponentName(owner.type); | | 28 | + return getComponentNameFromFiber(owner); | 29 | 29 | } | 30 | 30 | } | 31 | 31 | return null; | |
|