You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This actually is already handled properly by react-docgen:
What doesn't quite work is when the constants are in a separate file. The rationale for doing this is that many of our components take props like size, shape, theme, or shade and we want the values for these props to be consistent. However, not ALL of our components support all sizes for example. In other words, we want the values of size to be consistent across all our components, but each component may support only a subset of them. Same for shapes, or shades, etc.
Hi.
Per @danez suggestion in Create / use react-docgen vite plugin to show docsPage info by IanVS · Pull Request #299 · storybookjs/builder-vite, I'm opening a similar issue here.
TL;DR:
PropTypes.oneOf(Object.values(foo))
does not seem to work whenfoo
is an object containing values imported from an separate file.I created a repo that show this behavior in Storybook (clone,
npm install
thennpm run storybook
): sebastienbarre-forks/storybook-builder-vite-react-docgen-reproThe example was lifted from storybookjs/builder-vite: Getting started with Vite and Storybook (on a new project) using
build-vite
README:I slightly updated Button.jsx to use an object for the constants (this commit):
This actually is already handled properly by
react-docgen
:What doesn't quite work is when the constants are in a separate file. The rationale for doing this is that many of our components take props like
size
,shape
,theme
, orshade
and we want the values for these props to be consistent. However, not ALL of our components support all sizes for example. In other words, we want the values ofsize
to be consistent across all our components, but each component may support only a subset of them. Same for shapes, or shades, etc.It looks like this (this commit):
In
Size.js
:and the only change to Button is to use a subset of these sizes:
Here is what it looks like now in Storybook (notice the
null
):Here is what it seems react-docgen generates:
Thank you.
The text was updated successfully, but these errors were encountered: