From 8a4a5406754c319a40eda02e034a2cd4c720a918 Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Sat, 6 Jun 2020 02:42:55 -0700 Subject: [PATCH] fix: Move isEnum check first --- src/utils/propTypeInfo.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/utils/propTypeInfo.js b/src/utils/propTypeInfo.js index a95e74876..b58d9f7db 100644 --- a/src/utils/propTypeInfo.js +++ b/src/utils/propTypeInfo.js @@ -62,6 +62,15 @@ export const getDefaultValue = (component, propTypeName) => { return defaultValue; } + if (isEnum(component.propTypes[propTypeName])) { + const staticProperty = toStaticPropertyName(propTypeName); + const property = Object.entries(component[staticProperty]).find( + ([_, value]) => value === defaultValue + )[0]; + + return `${component.name}.${staticProperty}.${property}`; + } + if (typeof defaultValue === 'boolean') { return defaultValue.toString(); } @@ -74,15 +83,6 @@ export const getDefaultValue = (component, propTypeName) => { return undefined; } - if (isEnum(component.propTypes[propTypeName])) { - const staticProperty = toStaticPropertyName(propTypeName); - const property = Object.entries(component[staticProperty]).find( - ([_, value]) => value === defaultValue - )[0]; - - return `${component.name}.${staticProperty}.${property}`; - } - if (typeof defaultValue === 'number') { const specialNumber = findSpecialNumber(defaultValue);