diff --git a/addons/info/src/components/types/OneOf.js b/addons/info/src/components/types/OneOf.js index b10f27b89794..deacfa4633e8 100644 --- a/addons/info/src/components/types/OneOf.js +++ b/addons/info/src/components/types/OneOf.js @@ -1,13 +1,12 @@ import React from 'react'; import { TypeInfo, getPropTypes } from './proptypes'; -const OneOf = ({ propType }) => ( - - {getPropTypes(propType) - .map(({ value }) => value) - .join(' | ')} - -); +const joinValues = propTypes => propTypes.map(({ value }) => value).join(' | '); + +const OneOf = ({ propType }) => { + const propTypes = getPropTypes(propType); + return {`oneOf ${Array.isArray(propTypes) ? joinValues(propTypes) : propTypes}`}; +}; OneOf.propTypes = { propType: TypeInfo.isRequired, diff --git a/examples/official-storybook/components/DocgenButton.js b/examples/official-storybook/components/DocgenButton.js index bf327352abd1..8a1b11329d49 100644 --- a/examples/official-storybook/components/DocgenButton.js +++ b/examples/official-storybook/components/DocgenButton.js @@ -105,6 +105,7 @@ DocgenButton.propTypes = { * `oneOf` is basically an Enum which is also supported but can be pretty big. */ enm: PropTypes.oneOf(['News', 'Photos']), + enmEval: PropTypes.oneOf((() => ['News', 'Photos'])()), /** * A multi-type prop is also valid and is displayed as `Union` */ diff --git a/examples/official-storybook/stories/__snapshots__/addon-info.stories.storyshot b/examples/official-storybook/stories/__snapshots__/addon-info.stories.storyshot index c581d34dc47a..23b60d45f657 100644 --- a/examples/official-storybook/stories/__snapshots__/addon-info.stories.storyshot +++ b/examples/official-storybook/stories/__snapshots__/addon-info.stories.storyshot @@ -3592,6 +3592,31 @@ exports[`Storyshots Addon Info.React Docgen Comments from PropType declarations class="css-d52hbj" /> + + + enmEval + + + + + + - + + + - + + +