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.

styled-components and Glamorous support

See original GitHub issue

Further to this discussion https://github.com/styleguidist/react-styleguidist/issues/37

If you are using styled-components, you may have a component similar to:

import styled, { css } from "styled-components";
import PropTypes from "prop-types";

const Button = styled.a`
  background: transparent;
  color: white;

  ${({primary}) =>
    !!primary &&
    css`
      background: white;
      color: palevioletred;
    `};
`;

Button.propTypes = {
  primary: PropTypes.bool
};

export default Button;

or, with Glamorous:

import glamorous from "glamorous";
import PropTypes from "prop-types";

const Button = glamorous.button({
  background: "transparent",
  color: "white"
},
  ({ primary }) => (!!primary && {
    background: "white",
    color: "palevioletred"
  })
);

Button.propTypes = {
  primary: PropTypes.bool
};

This doesn’t import React, so afaik is why the react-docgen resolver does not pick it up as a valid component.

No suitable component definition found.

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.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:8
  • Comments:6

github_iconTop GitHub Comments

4reactions
jquensecommented, Aug 30, 2018

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

3reactions
chpeterscommented, Feb 26, 2018

I am seeing this issue as well using styled-components (through styled-system’s system function).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Glamorous vs styled-components | What are the differences?
Glamorous is React component styling solved with an elegant (inspired) API, small footprint (<5kb gzipped), and great performance (via glamor). It has a...
Read more >
glamorous - React component styling solved
Maintainable CSS with React ... Made with by PayPal and contributors.
Read more >
Styling React Components Using glamorous - DigitalOcean
glamorous is a flavor of CSS-in-JS. In this post, you'll see how you can style your components with it.
Read more >
Introducing glamorous - Kent C. Dodds
A styled-components and jsxstyle inspired solution for styling ⚛️ React Components from PayPal.
Read more >
Why We Use Styled Components at Decisiv | by Alan B Smith
I'm not saying Styled Components is better than Radium, Aphrodite, Glamor, Glamorous, Emotion, or any of the other CSS-in-JS libraries.
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