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] docgen descriptions do not work with component decorators #8134

Closed
DigTheDoug opened this issue Sep 19, 2019 · 9 comments
Closed

Comments

@DigTheDoug
Copy link

DigTheDoug commented Sep 19, 2019

Describe the bug
When using a component with a decorator, the component description and propType descriptions do not show up. Removing the decorator from the component allows them to show up.

To Reproduce
Steps to reproduce the behavior:

  1. Have a React Component with a decorator
  2. View the story in Storybook
  3. Click on the Docs tab
  4. See no description for component or proptypes
  5. Remove decorator.
  6. See descriptions in storybook docs tab.

Expected behavior
The description and propTypes description should display when a component is using a decorator.

Screenshots
With decorator
Screen Shot 2019-09-19 at 1 28 41 PM

Without decorator`
Screen Shot 2019-09-19 at 1 28 56 PM

Code snippets
ExampleComponent.jsx

import React, { Component, Fragment } from 'react';
import PropTypes from 'prop-types';

function exampleDecorator() {
  return DecoratedClass =>
    class extends Component {
      render() {
        return <DecoratedClass {...this.props}/>;
      }
    };
}

@exampleDecorator()
/**
 * The `ExampleComponent` component does a thing.
 */
export class ExampleComponent extends Component {
  
  render() {
    return (
      <Fragment>
        Display this here
      </Fragment>
    );
  }
}

ExampleComponent.propTypes = {
  /**
   * A map of CSS classes to be appended to DOM nodes internally
   */
  testParam: PropTypes.string,
};


ExampleComponent.defaultProps = {
  testParam: 'one'
};

ExampleComponent.stories.jsx

import React from 'react';
import { ExampleComponent } from './ExampleComponent';
import { storiesOf } from '@storybook/react';

storiesOf('ExampleComponent', module)
  .addParameters({
    component: ExampleComponent,
    componentSubtitle: 'The example component'
  })
  .add('Default', () => (
    <ExampleComponent/>
  ));

System:

  System:
    OS: macOS High Sierra 10.13.6
    CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
  Binaries:
    Node: 10.16.0 - ~/.nvm/versions/node/v10.16.0/bin/node
    Yarn: 1.12.1 - /usr/local/bin/yarn
    npm: 6.9.0 - ~/.nvm/versions/node/v10.16.0/bin/npm
  Browsers:
    Chrome: 76.0.3809.132
    Firefox: 68.0.2
    Safari: 12.1.2
  npmPackages:
    @storybook/addon-docs: ^5.2.0 => 5.2.0 
    @storybook/react: ^5.2.0 => 5.2.0 

Additional context
None

@salmanm
Copy link

salmanm commented Oct 3, 2019

I think this is the fix for it storybookjs/babel-plugin-react-docgen#74

Can someone please take a look?

@elevatebart @JeroenReumkens @shilman

@stale
Copy link

stale bot commented Oct 24, 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 Oct 24, 2019
@stale
Copy link

stale bot commented Nov 23, 2019

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 Nov 23, 2019
@Zunaib
Copy link

Zunaib commented Dec 6, 2019

Any update on this, cant seem to have description for props.

@shilman shilman added the todo label Dec 9, 2019
@shilman shilman reopened this Dec 9, 2019
@stale stale bot removed the inactive label Dec 9, 2019
@DigTheDoug
Copy link
Author

I tried the v5.3.0-beta.31 build which should include the possible fix @salmanm mentioned above (storybookjs/babel-plugin-react-docgen#74), but get the same results, so that unfortunately may not be the fix.

@DigTheDoug
Copy link
Author

To add some additional information, after updating all @storybook packages to 5.3.0-rc.0 I no longer see any props when using a decorator.

Screen Shot 2019-12-19 at 1 49 12 PM

It doesn't seem to matter using storiesOf or CSF format.

@lednhatkhanh
Copy link

Same for me, the props table is empty

@shilman
Copy link
Member

shilman commented Mar 4, 2020

As a workaround you can simply provide the undecorated component as the component metadata in your stories.

@DigTheDoug
Copy link
Author

In one of the recent updates (I'm on 5.3.12 but I haven't checked backwards) this was fixed somewhere. It works as expected for me now, so thanks!

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