mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Remove unnecessary null (#8858)
* Remove unnecessary null * always return string
This commit is contained in:
committed by
Dan Abramov
parent
7683211efd
commit
5170db8e72
@@ -15,11 +15,11 @@
|
||||
import type { ReactInstance } from 'ReactInstanceType';
|
||||
import type { Fiber } from 'ReactFiber';
|
||||
|
||||
function getComponentName(instanceOrFiber : ReactInstance | Fiber) : string | null {
|
||||
function getComponentName(instanceOrFiber : ReactInstance | Fiber) : string {
|
||||
if (typeof instanceOrFiber.getName === 'function') {
|
||||
// Stack reconciler
|
||||
const instance = ((instanceOrFiber : any) : ReactInstance);
|
||||
return instance.getName() || 'Component' || null;
|
||||
return instance.getName() || 'Component';
|
||||
}
|
||||
if (typeof instanceOrFiber.tag === 'number') {
|
||||
// Fiber reconciler
|
||||
@@ -29,10 +29,10 @@ function getComponentName(instanceOrFiber : ReactInstance | Fiber) : string | nu
|
||||
return type;
|
||||
}
|
||||
if (typeof type === 'function') {
|
||||
return type.displayName || type.name || null;
|
||||
return type.displayName || type.name || 'Component';
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return 'Component';
|
||||
}
|
||||
|
||||
module.exports = getComponentName;
|
||||
|
||||
Reference in New Issue
Block a user