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: Unwanted props appearing on the generated docs props. #8781

Closed
EdenTurgeman opened this issue Nov 10, 2019 · 12 comments
Closed

Addon docs: Unwanted props appearing on the generated docs props. #8781

EdenTurgeman opened this issue Nov 10, 2019 · 12 comments

Comments

@EdenTurgeman
Copy link

When viewing props from jsx using styled-components the props table will contain all props passed what seems to be styled-components

Example:
image
Also, for some reason, my docs page is not centered
image

Expected behavior
Only direct component props will be shown.
Docs are centered

My config:

import { configure, addDecorator } from '@storybook/react';
import { withOptions } from '@storybook/addon-options';
import { withKnobs } from '@storybook/addon-knobs';
import { bootstrap } from '@logz-ui/styleguide';

bootstrap();

const storyBookDecorators = [
  withKnobs,
  withOptions({
    name: `@logz-ui/styleguide`,
    url: 'https://github.com/logzio/gaia-hermes-ws/tree/master/styleguide',
    hierarchyRootSeparator: /\|/,
  }),
];

storyBookDecorators.forEach(addon => addDecorator(addon));

configure(require.context('../stories', true, /\.story\.jsx?$/), module);

My Presets:

module.exports = [
  {
    name: '@storybook/addon-docs/react/preset',
    options: {
      configureJSX: true,
      babelOptions: {
        babelrc: path ,
        presets: [],
        plugins: ['emotion'],
      },
      sourceLoaderOptions: null,
    },
  },
    {
      name: "@storybook/preset-typescript",
      options: {
        tsDocgenLoaderOptions: {
          tsconfigPath: path.resolve(__dirname, "../tsconfig.json")
        },
        include: [path.resolve(__dirname, "../stories")]
      }
    }
];

Will provide more context if needed. would love to know the solution to thesetwo problems :)

@patricklafrance
Copy link
Member

Hi @EdenTurgeman

You can fix this by specifying a propFilter to the tsDocgenLoaderOptions.

https://github.com/strothj/react-docgen-typescript-loader#loader-options

We should be able to excluded indirect props by default before the end of the beta.

@stale
Copy link

stale bot commented Dec 13, 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!

1 similar comment
@stale
Copy link

stale bot commented Jan 3, 2020

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 Jan 3, 2020
@stale
Copy link

stale bot commented Feb 2, 2020

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!

@stale stale bot closed this as completed Feb 2, 2020
@trumbitta
Copy link

We should be able to excluded indirect props by default before the end of the beta.

please reopen :)

Any updates on the quoted statement?

@shilman
Copy link
Member

shilman commented Apr 18, 2020

Jiminy cricket!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.0.0-alpha.39 containing PR #10464 that references this issue. Upgrade today to try it out!

You can find this prerelease on the @next NPM tag.

Closing this issue. Please re-open if you think there's still more to do.

@shilman shilman closed this as completed Apr 18, 2020
@shilman
Copy link
Member

shilman commented Apr 18, 2020

The above PR doesn't exactly solve this issue, but it adds a lot more flexibility and a workaround using the include prop

@skpandey1294
Copy link

skpandey1294 commented Aug 13, 2020

Hi @patricklafrance and @shilman I just want to know that the issue regarding indirect props is fixed or not? I am also facing similar problem. I am using Storybook 5.3.19

@trumbitta
Copy link

I'm in the process of updating to StoryBook 6 and there seem to be no need for my workaround anymore:

    config.module.rules.push({
      test: /\.(ts|tsx)$/,
      use: [
        {
          loader: require.resolve('react-docgen-typescript-loader'),
          options: {
            // Do not show additional props from styled-components, React, etc in the Props table
            // Waiting to be handled automatically by Storybook: https://github.com/storybookjs/storybook/issues/8781
            propFilter: (propInfo) =>
              propInfo && propInfo.parent && !propInfo.parent.fileName.includes('/node_modules/'),
          },
        },
      ],
    });

But now I don't see any of the props of my component, and instead see some of the props from styled-components:

image

@shilman
Copy link
Member

shilman commented Oct 15, 2020

Thanks @trumbitta . There are a few different ways to disable rows in the ArgsTable in 6.0:

I know we're a bit all over the place here. Sorry for the confusion.

cc @jonniebigodes

@trumbitta
Copy link

@shilman Thank you for the hints!

The include/exclude property looks promising and I'll probably try it today / tomorrow as I'm completing the migration to v6 🤞 🤞 🤞

@shilman
Copy link
Member

shilman commented Jun 14, 2023

Fixed by include/exclude above, available as both parameters and props in 7.0 https://storybook.js.org/docs/react/api/doc-block-argtypes

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

5 participants