From 5170db8e72e1301205b82c8a4e69b38b019bb868 Mon Sep 17 00:00:00 2001 From: Edvin Erikson Date: Tue, 24 Jan 2017 19:19:07 +0100 Subject: [PATCH] Remove unnecessary null (#8858) * Remove unnecessary null * always return string --- src/shared/utils/getComponentName.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/shared/utils/getComponentName.js b/src/shared/utils/getComponentName.js index b6ee95b703..302aa4ee89 100644 --- a/src/shared/utils/getComponentName.js +++ b/src/shared/utils/getComponentName.js @@ -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;