styleguidist / react-styleguidist

Isolated React component development environment with a living style guide
https://react-styleguidist.js.org/
MIT License
10.83k stars 1.44k forks source link

Proptypes doesn't show with @component annotation with emotionjs #1017

Closed kossel closed 6 years ago

kossel commented 6 years ago

We are spliting the UI with the styling of our components, eg: l Button.jsx

class Button extends React.Component {
  ...
  ...
}

Button.propTypes = {
  name: PropTypes.string,
}

export default Button;

StyledButton.jsx

import styled from 'react-emotion'

const StyledButton = styled(Button)(
  ...
  ...
)

StyledButton.propTypes = {
    size: PropTypes.string
}

export default StyledButton

PropTypes doesn't show in styleguide.

tried with @component annotation, without success (got warning TypeError: Attempted to resolveName for an unsupported path. resolveName accepts a VariableDeclaration, FunctionDeclaration, or FunctionExpression. Got "CallExpression".)

current our work around is create a wrapper component to trick styleguidist...

const ThemedButton = styled(Button)(
  ...
  ...
)

const StyledButton = (props) => <ThemedButton {...props} />

export default StyledButton

Is there a better way for this?

sapegin commented 6 years ago

When something isn’t working for you, include a reproducible demo:

  1. Fork the example project: https://github.com/styleguidist/example
  2. Modify it to reproduce the issue.
  3. Push to GitHub and paste the link here.

Most likely you’ll find an issue yourself, while creating a demo.

Issues without a demo will be closed!