addon-docs: Props doesn't work when using React.memo.
See original GitHub issueDescribe 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:
- Create Component in React and wrapped this with React.memo
- Run Storybook and open docs tab
- The prop table does not appear
Screenshots
Code snippets
Button.js
function Button({ label, onClick }) {
return (
<ButtonContainer onClick={onClick}>
<Label> {label} </Label>
</ButtonContainer>
);
}
Button.propTypes = {
label: PropTypes.string.isRequired,
onClick: PropTypes.func.isRequired,
};
export default React.memo(Button);
button.stories.mdx
# Button
Exemplo do **botão** padrão.
<Preview withToolbar>
<Story name="Default" height="100px" parameters={{ decorators: [withKnobs] }}>
<Button
labelColor={text("Label Color", theme.colors.white)}
onClick={() => alert("Button Click")} />
</Story>
</Preview>
## Props
<Props of={Button} />
System: OS: Linux 4.15 Ubuntu 18.04.3 LTS (Bionic Beaver) CPU: (4) x64 Intel® Core™ 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
Issue Analytics
- State:
- Created 4 years ago
- Reactions:11
- Comments:34 (16 by maintainers)
Top GitHub Comments
FWIW I discovered that
<Props of={MemoizedComponent.type} />
will correctly render a props table. No idea what’s going on under the hood there, lolUnsatisfying workaround is to also export your pure component and use that for documentation purposes