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.

addon-info: Component.__docgenInfo not defined.

See original GitHub issue

I can’t get the “description” field to show up in the PropType table in my project. I worked on #1030 with @bigassdragon and we had it working when all was done.

I tried with both methods to add info, and .__docgenInfo is undefined in both.

I did this in my config.js:

import { configure, setAddon } from '@storybook/react'
import infoAddon from '@storybook/addon-info'

setAddon(infoAddon)

window.STORYBOOK_REACT_CLASSES = {}

function loadStories () {
  require('../src/stories')
}

configure(loadStories, module)

and made stories that looked like this:

import React from 'react'

import { storiesOf } from '@storybook/react'
import { withInfo } from '@storybook/addon-info'

import Docs from './Docs'

storiesOf('Docs', module)
  .add('withInfo', withInfo('Heading here')(() => (<Docs name='David' />)))
  .addWithInfo('addWithInfo', 'Heading here', () => (<Docs name='David' />))

and Docs.js looks like this:

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

/** A dumb component that says "hello" */
export const Docs = ({name}) => (<div>Hello {name}</div>)

Docs.propTypes = {
  /** the name of the person to say "hello" to */
  name: PropTypes.string
}

Docs.defaultProps = {
  name: 'World'
}

export default Docs

I tried class Docs extends React.Component style, too.

Still no “description” field in either story: screen shot 2017-08-28 at 5 37 06 pm

screen shot 2017-08-28 at 5 41 47 pm

steps to reproduce:

npm i -g create-react-app @storybook/cli
create-react-app demo
cd demo
getstorybook
npm i -D @storybook/addon-info

Then I made changes, above.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
danielduancommented, Aug 29, 2017

export const Docs = ({name}) => (<div>Hello {name}</div>) doesn’t work unfortunately.

If you delete export, it should be okay. It’s a bug in https://github.com/storybooks/babel-plugin-react-docgen/issues/33 with the React component detection. Feel free to submit a PR, we basically parse the AST to figure out if its an exported React component before sending it off to docgen for parsing.

Part of me wonders why we’re even parsing the AST of the files in the babel plugin because react-docgen will reparse it again. I’m not sure we gain much from the performance boost either. Anyway, that’s a whole separate issue.

1reaction
konsumercommented, Sep 3, 2017

I made a PR to change the behavior of the resolver but as @danez pointed out, the resolver is actually configurable, and there are a few built in (maybe findAllComponentDefinitions does what I want?) I propose that we use that as the default, instead. I like the idea of the default storybook doc-resolver grabbing all the exported stuff, but then using it’s own “this is what this story is about” resolution to pick out the right doc object to actually show. I will do some experimentation with this and come back with a PR, if people like this idea.

Read more comments on GitHub >

github_iconTop Results From Across the Web

addon-info: Component.__docgenInfo not defined. · Issue #1762
I tried with both methods to add info, and .__docgenInfo is undefined in both. I did this in my config.js: import { configure ......
Read more >
storybook-addon-react-docgen
A storybook addon to display react docgen info. ... If you are using @storybook/addon-docs then you do not need to set up docgen...
Read more >
@esqimoe/react-docgen-typescript-loader - npm
Webpack loader to generate docgen information from TypeScript React components. The primary use case is to get the prop types table ...
Read more >
@storybook/addon-storysource | Yarn - Package Manager
Angular: Fix "webpack_require.nmd is not a function issue" in Angular 15 #20043; CLI/React native: Fix addons template to import register instead of manager ......
Read more >
storybook-addon-react-docgen/README.md - UNPKG
5, A storybook addon to display react docgen info. ... 25, If you are using `@storybook/addon-docs` then you do not need to set...
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