Does not work with `class` Components
See original GitHub issueI am trying to extract prop-types info from a component in storybook.
I am using the default babel-plugin-react-docgen
that comes baked in to @storybook/react@4.1.7
which is at version 2.0.0
It looks like that uses react-docgen@3.0.0-rc.1
When I console.log(Component.__docgenInfo)
in a story file for a Component that is defined with class
:
class Component extends React.Component {...}
When I do the same thing in a story file for a Component that is defined with function, everything seems to work as expected.
function Component() {...}
However, if I use react-docgen
cli to generate the docgen info, I get all of the expected info from the class
based Component.
npx react-docgen ./src/components/Component.jsx
Any help would be appreciated on why this might not be working.
I tried to just generate/parse the react docgen in the story file without the babel plugin, but I can’t seem to get the full untranspile source from the story file.
Here is my .babelrc
{
"presets": [
[
"@babel/preset-env",
{
"useBuiltIns": "usage"
}
],
"@babel/preset-react"
],
"plugins": [
"transform-class-properties",
[
"module-resolver",
{
"root": ["."],
"alias": {
"storybook": ["./.storybook"]
}
}
]
]
}
babel-plugin-react-docgen
is coming from storybook, but I did try to add it with a custom name, still no luck.- I tried removing
transform-class-properties
to no avail
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:12 (2 by maintainers)
Have the same issue. Didn’t use any
.babelrc
. just CRAStill does not work for me. I’m using v4.0.1.
Webpack custom configuration:
I think that this issue should be reopened.