Skip to content
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

Build ignores argTypes/PropTypes to create controls table #17310

Open
dxxglas opened this issue Jan 21, 2022 · 5 comments
Open

Build ignores argTypes/PropTypes to create controls table #17310

dxxglas opened this issue Jan 21, 2022 · 5 comments

Comments

@dxxglas
Copy link

dxxglas commented Jan 21, 2022

When creating a new component and its stories in Storybook, I can configure the controls table using PropTypes and argTypes and see it working as expected using the yarn storybook. However, when compiling the project with yarn build-storybook the behavior is different, all the props imported from the component are displayed.

In the image below, the yarn storybook behavior is on the left and the yarn build-storybook behavior is on the right.

storybook-compare

The component and story file code is described below.

Button.tsx

import { Button as MUIButton, ButtonProps } from '@mui/material';
import PropTypes from 'prop-types';

export const Button = ({ variant, size, ...props}: ButtonProps) => {
    return <MUIButton variant={variant} size={size} {...props} />
};

Button.propTypes = {
    variant: PropTypes.string,
    size: PropTypes.string,
};

Button.defaultProps = {
    variant: 'contained',
    size: 'large',
}

Button.stories.tsx

import { Button } from './Button';

export default {
    title: 'Button',
    component: Button,
    argTypes: {
        disabled: {
            control: { type: 'boolean' },
        },
    },
};

export const Default = ({ ...args }) => <Button {...args} />;
Default.args = {
    children: 'Default',
    disabled: false,
};
@shilman
Copy link
Member

shilman commented Jan 22, 2022

Do you a have a reproduction repo you can share? If not, can you create one? See how to create a repro. Thank you! 🙏

@dxxglas
Copy link
Author

dxxglas commented Jan 24, 2022

I tried to use the command npx sb@next repro, but I can't follow all the steps, I end up getting errors when installing yarn. Anyway, I put the code used to reproduce this error in this repository, running yarn storybook and yarn build-storybook you should be able to reproduce the behavior. Thank you for your attention.

@kailo777
Copy link

We are facing the same issue as well that the deployed storybook envrioment have less PropTypes and argTypes then the local deployed version.

@AleSergio
Copy link

We are currently facing the same issue as described above.

@kasperskov909
Copy link

I wonder if you'll get the same result if you inline your import. This might be a react-docgen thing.
Me and many other have the opposite problem. We need imported and inherited props to be rendered when they are not.

Are your size and variant argTypes rendered correctly with radiobuttons when using yarn build-storybook?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants