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.

PropTable does not work with styled-component

See original GitHub issue

Bug 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

  1. Create a styled-component
  2. Import it into an .mdx file
  3. start docz dev server
  4. See error

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:6
  • Comments:11

github_iconTop GitHub Comments

6reactions
pcooney10commented, Jan 8, 2019

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

3reactions
Raphalex46commented, Jul 9, 2020

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…

Read more comments on GitHub >

github_iconTop 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 >

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