PropTable does not work with styled-component
See original GitHub issueBug Report
Describe the bug PropTable won’t render for a styled-component like the following:
// Header.js
import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
const Header = styled.header`
z-index: 100;
background-color: ${props => props.bg};
min-height: 3rem;
width: 100%;
font-size: 0.875rem;
font-weight: 600;
line-height: 1rem;
display: flex;
align-items: center;
`;
Header.defaultProps = {
bg: #333,
};
Header.propTypes = {
children: PropTypes.node.isRequired,
bg: PropTypes.string,
};
export default Header;
---
name: Header
menu: Components
---
import { PropsTable } from 'docz';
import Header from './Header';
# Header
## Properties
<PropsTable of={Header} />
To Reproduce
- Create a styled-component
- Import it into an .mdx file
- start docz dev server
- See error
Issue Analytics
- State:
- Created 5 years ago
- Reactions:6
- Comments:11
Top Results From Across the Web
Props table issue from styled component interface in addon ...
I have styled-component added to Storybook but the props table is not showing any custom props defined on the component.
Read more >Using styled components with Typescript, prop does not exist?
The styled component will have to specify the prop to pass to the component like styled("h2")<IProps> . You can read more about the...
Read more >API Reference - styled-components
A function that receives the props that are passed into the component and computes a value, that is then going to be merged...
Read more >Create a reusable table with react, styled-components and ...
We want the end-users of our components to be able to customize them so we are taking everything they are passing as props...
Read more >styled-components - npm
styled -components is compatible with both React (for web) and React Native – meaning it's the perfect choice even for truly universal apps!...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Digging a bit more, it seems to be related to the ‘docgen parser’: https://github.com/pedronauck/docz/issues/347#issuecomment-425154378
And will be resolved in v0.14: https://github.com/pedronauck/docz/issues/240#issuecomment-449506318
Why is this closed ? I think a lot of React projects use styled components, and using a workaround like the one that was suggested is not an option for everybody. This seems like quite a simple fix, and it would be great to get rid of this little bug. The problem with the workaround is also that it makes little sense to change your real code for the sake of documentation, it’s weird.
The stale bot is also a real problem here. It’s not because the issue is stale that the issue is invalid…