-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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: Props doesn't work when using React.memo. #9586
Comments
Unsatisfying workaround is to also export your pure component and use that for documentation purposes |
I ran into the same problem and found a solution some time ago: add the proptypes to the memo'ed component and you will be fine. Also I believe this has less to do than storybook than with the way the PropTypes work. |
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! |
Repro: ee4144a |
Sorry for the shameless bump, but is this scheduled to be fixed in an upcoming release? :) |
@breytex we've consolidated on |
@shilman Is it available in 5.3.x? What should be changed here:
|
@Vanuan Yeah, it should be available in 5.3.x. You can should be able to add |
Still not working if I use default export. |
What I also noticed is when I use named export, which is currently a working solution rignt now, docs doesn't read the children prop, even if I specifically declare that in my interface. |
@mkinfrared are you using |
@shilman I'm using |
@mkinfrared it's a known issue in RDTL that's fixed in |
@mkinfrared if you submit a pr to |
FWIW I discovered that |
Bump I am on version 6 now.
Strangely it seems to work fine for normal function component. Any workaround for the same. |
@SomilKumar what happens when you set:
|
Hi I am using forwardRef in my components and met the same problem, I tried your solution like
When I wrote this in my Input.stories, the props is not loaded, I even could not see the box with 'No props found for this component'. I am on |
@shilman it doesn't render the story altogether. Both for memoized component and normal functional component. |
@shilman Open PR to |
Thanks @hipstersmoothie ! Merged 11 days ago and released in v1.20.4 of react-docgen-typescript. I can confirm my deps went from Unfortunately I still have to unwrap memo from my components or export them separately for documentation as even with your updates there is no documentation from when wrapped in memo |
if you get a sample repo up I can take a look |
@hipstersmoothie thanks Andrew! (I am also an Andrew!) Here's the requested repo for you! https://github.com/tm1000/storybook-repro Look in the stories folder. I commented by providing two examples. One with the direct export (which works) and one with the wrapped export (using memo, does not work) |
Thanks! |
I am not sure if this is resolved, but I am still facing the same issue, where controls ( props ) are not getting generated automatically if I wrap my components using React.memo |
Oh god this solved the same problem I was facing. |
@BhanuSanghi-Dev well... it should be fixed looking at the code changes on |
I was able to resolve this by changing my component from
to
and then in storybook doing the
|
Actually, the exported component is the same in both cases. My PR should make this unnecessary 👍 |
Olé!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.1.0-alpha.21 containing PR #12686 that references this issue. Upgrade today to try it out! You can find this prerelease on the |
Came to this Issue while searching for a similar problem. Below is an example: import { ButtonHTMLAttributes, memo, PropsWithChildren } from 'react';
import * as S from './styles';
export interface ButtonProps extends S.StyledButtonProps, ButtonHTMLAttributes<HTMLButtonElement> {}
const Component = (props: PropsWithChildren<ButtonProps>) => {
const { onClick, isLoading, children, ...rest } = props
return (
<S.Container onClick={onClick} isLoading={isLoading} {...rest} >
{children}
</S.Container>
);
}
Component.defaultProps = {
type: 'button',
variant: 'primary',
className: '',
fixedWidth: false,
isLoading: false,
} as ButtonProps
export const Button = memo(Component) |
@andezzat is default value something you can look into? |
I encountered the same issue as @lukemorales had. The description and default value of each prop is not being filled. I ended up using the workaround in the 1st comment. |
Describe the bug
I trying show the props in docs page using
<Props of={Component}/>
in .mdx file. But i receive this message "No props found for this component"To Reproduce
Steps to reproduce the behavior:
Screenshots
Code snippets
Button.js
button.stories.mdx
System:
OS: Linux 4.15 Ubuntu 18.04.3 LTS (Bionic Beaver)
CPU: (4) x64 Intel(R) Core(TM) i5-3570 CPU @ 3.40GHz
Binaries:
Node: 10.15.3 - /usr/local/bin/node
Yarn: 1.19.1 - /usr/bin/yarn
npm: 6.4.1 - /usr/local/bin/npm
Browsers:
Chrome: 78.0.3904.108
Firefox: 72.0.1
npmPackages:
@storybook/addon-actions: 5.3.7 => 5.3.7
@storybook/addon-backgrounds: 5.3.7 => 5.3.7
@storybook/addon-centered: 5.3.7 => 5.3.7
@storybook/addon-docs: 5.3.7 => 5.3.7
@storybook/addon-knobs: 5.3.7 => 5.3.7
@storybook/addon-storysource: 5.3.7 => 5.3.7
@storybook/addon-viewport: 5.3.7 => 5.3.7
@storybook/core: 5.3.7 => 5.3.7
@storybook/react: 5.3.7 => 5.3.7
@storybook/theming: 5.3.7 => 5.3.7
npmGlobalPackages:
@storybook/cli: 5.3.4
The text was updated successfully, but these errors were encountered: