From f1b0402d83d539e35c45ec658cf2f296da64d5b1 Mon Sep 17 00:00:00 2001 From: lbaker Date: Wed, 10 Jun 2020 13:30:37 -0700 Subject: [PATCH] fix: Add check for propTypes in getTypeDefs --- src/hooks/useComponentDoc.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/hooks/useComponentDoc.js b/src/hooks/useComponentDoc.js index 0f26c373a..4b8bdb528 100644 --- a/src/hooks/useComponentDoc.js +++ b/src/hooks/useComponentDoc.js @@ -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)