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 - build prop table from dynamic propTypes? #10536
Comments
does it work in react-docgen? if not, i don't think it will ever work in storybook since we rely on that to generate the props tables. we have some hacked up (sorry @patricklafrance, not trying to insult) code that does some degree of dynamism, but there's only so far we can go with this approach ... and it's a maintenance nightmare. @patricklafrance the other option is to make propType processing fully dynamic. i think we had this at one point but you deleted it. bringing this back might actually be simpler than the current setup. WDYT? |
@shilman docgen goes like this for me: |
See #8527 and the the community-created webpack loader |
I don't think this ever worked @shilman even before my changes since the props table always relied on docgen to loop through the component props and docgen doesn't return props from external objects. It works when using a spread operator for a local object, but not for an external object. BTW, you should add this use case to your recurring issues docs since it's like the 15th issues about this ;) |
I feel like this is a dupe because I've had this exact same issue. @azinod There's an unfinished PR open in the react-docgen project that was aimed to address this, so you might wanna upvote/nudge/etc. in that thread to try and keep things moving. 👍 |
@patricklafrance I'm thinking about bringing back the dynamic propTypes code that you deleted in 5.3 and using that to handle this case. WDYT? |
@shilman no strong opinion, if you feel you need it, go ahead. |
@patricklafrance Do you think it will also handle what we’re currently using acorn for? |
@shilman no |
Hey I'm also running into this issue, +1 for a potential solution. If I'm reading this correctly, there is no existing solution for generating a props table for any components propTypes that are composed from another imported component's propTypes? |
@jtieu-r7 currently that's the case, do to limitations of |
Hi @shilman , I started using addon-docs and see the dynamic prop types problem. |
In SB6 you can manually define argtypes that will get rendered into the table: https://github.com/storybookjs/storybook/blob/next/addons/docs/docs/props-tables.md#customizing-argtypes |
I want to create costume argTypes in MXD format. I didn't see an example of creating costume argTypes in MDX format in the docs. |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook! |
This is still an issue |
The issue may have been resolved in react-docgen: |
Seems to still be an issue in 6.2.8 |
This makes storybook automatic For Docs to be truly beneficial, automatic It is extremely unreliable & hassle for developers to manually maintain both the "real" propTypes (on the components themselves) and in another file, only for Storybook presentation, especially for large projects with dozens of developers at different skill levels |
closing this as dupe to #14092 |
Describe the bug
Using the Addon-Docs, I am not being able to get a prop table from a component that has dynamic propTypes. By dynamic propTypes I mean: propTypes built by destructuring objects into the propTypes object rather than defining static properties, which is what we normally do.
This approach is used by styled-systems and similar libraries.
To Reproduce
Create a component with dynamic propTypes (like the one below) in a React application with storybook and Addon-Docs and try to get the prop table for that component with the dynamic/destructured propTypes in it.
What happened when I tried was:
Code snippet
Expected behavior
All props in propTypes to display in the prop table, including the dynamic ones added via destructuring.
System:
Environment Info:
System:
OS: Linux 4.4 Ubuntu 16.04.3 LTS (Xenial Xerus) (actually using windows WSL)
CPU: (4) x64 Intel(R) Core(TM) i5-5300U CPU @ 2.30GHz
Binaries:
Node: 10.19.0 - ~/.nvm/versions/node/v10.19.0/bin/node
Yarn: 1.17.3 - /mnt/c/Program Files (x86)/Yarn/bin/yarn
npm: 6.13.4 - ~/.nvm/versions/node/v10.19.0/bin/npm
npmPackages:
@storybook/addon-a11y: ^5.3.18 => 5.3.18
@storybook/addon-actions: ^5.3.18 => 5.3.18
@storybook/addon-docs: ^5.3.18 => 5.3.18
@storybook/addon-knobs: ^5.3.18 => 5.3.18
@storybook/addon-links: ^5.3.18 => 5.3.18
@storybook/addon-storysource: ^5.3.18 => 5.3.18
@storybook/addon-viewport: ^5.3.18 => 5.3.18
@storybook/addons: ^5.3.18 => 5.3.18
@storybook/react: ^5.3.18 => 5.3.18
The text was updated successfully, but these errors were encountered: