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

[addon-docs] Props component render defaultProps from the last component from the file #8740

Closed
lgraziani2712 opened this issue Nov 6, 2019 · 3 comments

Comments

@lgraziani2712
Copy link
Contributor

Describe the bug

I have a MDX file that renders the Props for a component from a file with two components. The default value for one of its props has the value from the defaultProps of the last component. If I change the order of them, it changes the default value being rendered.

BTW, I'm using the typescript-preset.

To Reproduce
Steps to reproduce the behavior:

  1. Create a tsx files with two named export components and configure a prop with default value for each of them. That prop must have the same name for both of them but different accepted values.
  2. Create a mdx story.
  3. Import one or both (it doesn't matter) components and render their props.
  4. Change the order of the components (in the tsx file).
  5. See how the default value changes to the value of the last component.

Expected behavior
To respect the default value for each component.

Screenshots

image

Code snippets

export interface ElemAProps {
  size?: 'a' | 'b' | 'c' | 'd';
}

export const ElemA: React.SFC<ElemAProps> = ({ size = 'a', children }) => (
  <div className={size}>{children}</div>
);

export interface ElemBProps {
  size?: 'sm' | 'md' | 'lg';
}

export const Paragraph: React.SFC<ElemBProps> = props => (
  <div className={props.size}>{props.children}</div>
);

ElemBProps.defaultProps = { size: 'md' };

System:

  System:
    OS: Linux 4.15 Ubuntu 18.04.3 LTS (Bionic Beaver)
    CPU: (4) x64 Intel(R) Core(TM) i7-4510U CPU @ 2.00GHz
  Binaries:
    Node: 10.16.0 - ~/.nvm/versions/node/v10.16.0/bin/node
    Yarn: 1.19.1 - /usr/bin/yarn
    npm: 6.9.0 - ~/.nvm/versions/node/v10.16.0/bin/npm
  Browsers:
    Chrome: 78.0.3904.87
    Firefox: 71.0b7
  npmPackages:
    @storybook/addon-actions: 5.2.5 => 5.2.5 
    @storybook/addon-backgrounds: 5.2.5 => 5.2.5 
    @storybook/addon-docs: 5.2.5 => 5.2.5 
    @storybook/addon-knobs: 5.2.5 => 5.2.5 
    @storybook/preset-typescript: 1.1.0 => 1.1.0 
    @storybook/react: 5.2.5 => 5.2.5 
@stale stale bot added the inactive label Nov 28, 2019
@storybookjs storybookjs deleted a comment from stale bot Nov 28, 2019
@stale stale bot removed the inactive label Nov 28, 2019
@stale
Copy link

stale bot commented Dec 19, 2019

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!

@stale stale bot added the inactive label Dec 19, 2019
@shilman shilman added the todo label Dec 20, 2019
@stale stale bot removed the inactive label Dec 20, 2019
shilman added a commit that referenced this issue Feb 14, 2020
@shilman
Copy link
Member

shilman commented Feb 14, 2020

Repro: 85e4f6d

@shilman
Copy link
Member

shilman commented Jun 7, 2023

We’re cleaning house! Storybook has changed a lot since this issue was created and we don’t know if it’s still valid.

Please open a new issue referencing this one if:

@shilman shilman closed this as completed Jun 7, 2023
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

2 participants