-
-
Notifications
You must be signed in to change notification settings - Fork 301
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
styled-components and Glamorous support #256
Comments
I am seeing this issue as well using styled-components (through styled-system's |
Generate `API.md` by calling `npm run docs`. This uses react-docgen. Due to the default resolver of react-docgen not picking up Glamorous components, I've had to wrap some Glamorous only components with a JSX wrapper. I'd rather not have to do this but not sure of any alternative solution. reactjs/react-docgen#256 I'm also not sure the format of the current API.md is useful but opening PR for consideration.
Ran into this issue with the Storybook Info Addon. Tracked it down to this function in their code, which made me realize it is an issue with react-docgen parsing styled-components, this information brought me here - noting for others. This is what react-docgen is able to get from the styled-component with a docgen style description on the prop: {
"property": "children",
"propType": "node",
"required": true,
"description": null
} When other react components look like: {
"property": "children",
"propType": {
"name": "node"
},
"required": true,
"description": "Heading text or node"
} |
if anyone is interested this is what we came up with for css-literal-loader, but the syntax is the same for styled components or emotion, so this should work for them as well: https://gist.github.com/jquense/c2a92f1c909552f295bb7953fcd2ce4d |
I have a solution/workaround for this issue:
By changing this up a little and adding prop types to both the react-component and the styled-component wrapper it's now possible to read prop-types from the exported component and it still keeps eslint "react/prop-types" happy :)
It adds a little bit more code, and it's not suuuuper sexy, but it gets the job done. |
I wonder if we should close this im using (and released) https://www.npmjs.com/package/react-docgen-styled-resolver which does need a README but works great |
Further to this discussion styleguidist/react-styleguidist#37
If you are using styled-components, you may have a component similar to:
or, with Glamorous:
This doesn't import React, so afaik is why the react-docgen resolver does not pick it up as a valid component.
Is there an existing way to get this to work e.g. with a custom resolver? Or is a bugfix/new feature needed?
#195 looks like it resolves this, and is marked as closed as the feature in v3. I've installed
react-docgen@3.0.0-beta11
but still get the issue with the above 2 examples.The text was updated successfully, but these errors were encountered: