Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addon-docs: Check if component propTypes exists before unwrapping #8665

Merged
merged 1 commit into from
Nov 1, 2019

Conversation

donysukardi
Copy link
Contributor

@donysukardi donysukardi commented Nov 1, 2019

Issue: Fixes #8664

What I did

Check if propTypes exists in supplied type before trying to unwrap when extracting props for docs.

The function should be able to extract the props for the following type of component

const Component = forwardRef((props, ref) => (/* ... */);

Component.propTypes = {
  /* some prop types */
}

How to test

  • Is this testable with Jest or Chromatic screenshots?
  • Does this need a new example in the kitchen sink apps?
  • Does this need an update to the documentation?

If your answer is yes to any of these, please make sure to include it in your PR.

I'm not sure if there are already existing tests for this functionality. I'd be glad to add more test cases if there are.

@vercel
Copy link

vercel bot commented Nov 1, 2019

This pull request is being automatically deployed with ZEIT Now (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://zeit.co/storybook/monorepo/crquwfy6l
🌍 Preview: https://monorepo-git-fork-donysukardi-extract-props.storybook.now.sh

@patricklafrance
Copy link
Member

This fix LGTM @shilman

Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@shilman shilman changed the title Check if propTypes exists in supplied type before trying to unwrap when extracting props Addon-docs: Check if propTypes exists on component before unwrapping Nov 1, 2019
@shilman shilman added addon: docs bug patch:yes Bugfix & documentation PR that need to be picked to main branch labels Nov 1, 2019
@shilman shilman added this to the 5.2.x milestone Nov 1, 2019
@shilman shilman merged commit 6996eb4 into storybookjs:next Nov 1, 2019
@shilman shilman changed the title Addon-docs: Check if propTypes exists on component before unwrapping Addon-docs: Check if component propTypes exists before unwrapping Nov 1, 2019
@shilman shilman removed the patch:yes Bugfix & documentation PR that need to be picked to main branch label Dec 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Docs] extractProps assumes propTypes to be in wrapped component
3 participants