Skip to content

Commit

Permalink
fix: Add check for propTypes in getTypeDefs
Browse files Browse the repository at this point in the history
  • Loading branch information
LizBaker committed Jun 10, 2020
1 parent 481c62d commit f1b0402
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/hooks/useComponentDoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ const getTypeDefs = (component) => {
.map((key) => component[key]?.__docs__?.tags)
.filter(Boolean);

const tagsFromPropTypes = Object.getOwnPropertyNames(component.propTypes).map(
(key) => component.propTypes[key]?.__docs__?.tags
);
const tagsFromPropTypes = component.propTypes
? Object.getOwnPropertyNames(component.propTypes).map(
(key) => component.propTypes[key]?.__docs__?.tags
)
: [];

const componentTypeDefNames = tagsFromComponentProperties
.concat(tagsFromPropTypes)
Expand Down

0 comments on commit f1b0402

Please sign in to comment.