question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No props appearing for named function export with Addon-docs

See original GitHub issue

Describe the bug Been trying various things to get the props to appear for my component library with no luck. This is using the 5.3.0-rc.0 version of Storybook and Addon-docs.

I’ve been trying with both js and mdx file types and seeing no success. A named function export, with props and comments, renders in the Docs file with “No props found for this component”.

I’ve set up the MDX rules following the Manual configuration guide on the README.

Expected behavior Props should be populated in Docs.

Code snippets Component:

import React from 'react'
import PropTypes from 'prop-types'

export const Dummy = ({
  textProp
}) => {
  return (
    <div>
      { textProp }
    </div>
  )
}

Dummy.propTypes = {
  /**
   * Test code export
   */
  textProp: PropTypes.string.isRequired,
}

MDX:

import { Meta, Props, Preview, Story } from '@storybook/addon-docs/blocks'
import { Dummy } from './'

<Meta
  title="mdx/dummy"
  component={Dummy}
/>

# Test

<Preview>
  <Story name="testing">
    <Dummy textProp="Hello world" />
  </Story>
</Preview>

## Props

<Props of={Dummy} />

Screenshots Screenshot 2019-12-20 at 09 52 22

System:

  System:
    OS: macOS 10.15.1
    CPU: (4) x64 Intel(R) Core(TM) i5-7267U CPU @ 3.10GHz
  Binaries:
    Node: 11.13.0 - ~/.nvm/versions/node/v11.13.0/bin/node
    Yarn: 1.21.1 - ~/.yarn/bin/yarn
    npm: 6.7.0 - ~/.nvm/versions/node/v11.13.0/bin/npm
  Browsers:
    Chrome: 79.0.3945.88
    Safari: 13.0.3
  npmPackages:
    @storybook/addon-a11y: ^5.3.0-rc.0 => 5.3.0-rc.0 
    @storybook/addon-contexts: ^5.3.0-rc.0 => 5.3.0-rc.0 
    @storybook/addon-docs: ^5.3.0-rc.0 => 5.3.0-rc.0 
    @storybook/addon-knobs: ^5.3.0-rc.0 => 5.3.0-rc.0 
    @storybook/addon-links: ^5.3.0-rc.0 => 5.3.0-rc.0 
    @storybook/addon-viewport: ^5.3.0-rc.0 => 5.3.0-rc.0 
    @storybook/addons: ^5.3.0-rc.0 => 5.3.0-rc.0 
    @storybook/preset-scss: ^1.0.2 => 1.0.2 
    @storybook/react: ^5.3.0-rc.0 => 5.3.0-rc.0 
    @storybook/theming: ^5.3.0-rc.0 => 5.3.0-rc.0

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:9
  • Comments:46 (11 by maintainers)

github_iconTop GitHub Comments

8reactions
Zunaibcommented, Dec 27, 2019

Try doing this, got out of the same problem.

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

export interface DummyProps extends HTMLAttributes<HTMLElement> {
textProp:string;
 };

export const Dummy: FC<DummyProps > = function ({ textProp }) {
 return (
    <div>
      { textProp }
    </div>
  );
};

Dummy.propTypes = {
  /**
   * Test code export
   */
  textProp: PropTypes.string.isRequired,
};

export default Dummy;
6reactions
thehulkecommented, Mar 24, 2020

@getignited Hey, Have you tried import * as React from 'react' in your component?

Read more comments on GitHub >

github_iconTop Results From Across the Web

No props appearing for named function export with Addon ...
I've set up the MDX rules following the Manual configuration guide on the README. Expected behavior Props should be populated in Docs. Code...
Read more >
StoryBook addon-docs: "No props found for this component ...
I was able to solve this issue, basically I had misconfigured the webpack.config.js for StoryBook,
Read more >
Docs Addon | Storybook: Frontend workshop for UI development
module.exports = { addons: [ { name: '@storybook/addon-docs ...
Read more >
Documenting design systems with Storybook Docs
named export — functions that describe the stories ... import { Canvas, Meta, Story } from '@storybook/addon-docs/blocks' ...
Read more >
Storybook Docs with mdx support and addon knobs - Medium
name : '@storybook/addon-docs', // new addon for docs ... as well as showing the props accepted and a copy and paste version of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found