Skip to content

Commit

Permalink
fix: Move isEnum check first
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Jun 6, 2020
1 parent a1d0ec3 commit 8a4a540
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/utils/propTypeInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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);

Expand Down

0 comments on commit 8a4a540

Please sign in to comment.