Skip to content

Commit

Permalink
fix: adds an early return on defaultprops retrieval
Browse files Browse the repository at this point in the history
- this prevents potential errors around fewer/more hooks being rendered
  • Loading branch information
mgadewoll committed Jul 2, 2024
1 parent 56f1801 commit 4bbba27
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -330,15 +330,17 @@ export const getDefaultPropsfromDocgenInfo = (
): Record<string, any> | undefined => {
if (typeof component.type === 'string') return;

if (!isStoryComponent(component, context)) return;

// determine the story element first
// this is required because the story might be wrapped and
// only the story element has the required docgenInfo
let storyComponent: ReactElementWithDocgenInfo | undefined =
const storyComponent: ReactElementWithDocgenInfo | undefined =
getStoryComponent(component, context);

if (!storyComponent) return;

let propsInfo =
const propsInfo =
isEmotionComponent(storyComponent) &&
typeof storyComponent.props?.[EMOTION_TYPE_KEY] !== 'string'
? storyComponent.props?.[EMOTION_TYPE_KEY]?.__docgenInfo.props
Expand Down

0 comments on commit 4bbba27

Please sign in to comment.