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 Info] - Error when using oneOf propType and a evaluation #2652

Closed
theAbeGonzalez opened this issue Jan 5, 2018 · 3 comments
Closed

Comments

@theAbeGonzalez
Copy link
Contributor

Issue details

What did you expect to happen?
Tried to display the propTable of a component that has a code evaluation in the propTypes declaration.

What happened instead?
Error propType.value.map is not a function was displayed

Steps to reproduce

Create a component with a evaluation in the propTypes declaration.
Add a story withInfo with an object defining the propTables to display the component.
withInfo({ propTables: [Button] })(() => (...))
Run the storybook

Please specify which version of Storybook and optionally any affected addons that you're running

  • @storybook/react 3.2.12
  • @storybook/addon-info 3.2.12

Screenshots / Screencast / Code Snippets (Optional)

import {values} from 'lodash'

const KIND = {
  PRIMARY: 'primary',
  SECONDARY: 'secondary'
}

const Button = props => (
 ...
)

Button.propTypes = {
/** Type of button **/
  type: oneOf(() => (['hello', 'again'])()),  // <- code evaluation
/** kind of button **/
  kind: oneOf(values(KIND)),  // <- code evaluation
}

@theAbeGonzalez theAbeGonzalez changed the title Error when using oneOf propType and a evaluation Info Addon - Error when using oneOf propType and a evaluation Jan 5, 2018
@theAbeGonzalez theAbeGonzalez changed the title Info Addon - Error when using oneOf propType and a evaluation [Addon Info] - Error when using oneOf propType and a evaluation Jan 5, 2018
fspoettel pushed a commit to react-lds/react-lds that referenced this issue Jan 24, 2018
can't use newer versions until storybookjs/storybook#2652 is resolved
@thompsongl
Copy link

Certainly does not solve the underlying problem, but here's a workaround that renders and allows for correct proptype validation:

const KIND = {
  PRIMARY: 'primary',
  SECONDARY: 'secondary'
}
const kindVals = values(KIND)

Button.propTypes = {
  kind: oneOf([...kindVals])
}

@lhnrd
Copy link

lhnrd commented Feb 7, 2018

Any updates on this issue?

@Hypnosphi
Copy link
Member

Released 3.3.14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants