-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support imported propTypes #917
Comments
@sapegin somebody already published a modified version of this: siddharthkp/react-docgen-external-proptypes-handler |
does it work? If yes, could you put an example of integration into commonPropTypes.js import PropTypes from 'prop-types'
export default {
top: PropTypes.string
} MyComponent.js import commonPropTypes from './commonPropTypes'
const MyComponent = () => {}
MyComponent.propTypes = {
...commonPropTypes
}
export default MyComponent but without success. |
@peroperje look at MoneyInput propTypes https://github.com/alfa-laboratory/arui-feather/blob/master/src/money-input/money-input.jsx and to config for react-styleguidist |
Thanks, @stepancar. propsParser(filePath) {
return reactDoc(filePath);
} in my styleguide.config.js all propTypes for all components disappears from the documentation. I am not sure what I do wrong. |
@peroperje could you provide repo where you use react-styleguidist? |
@stepancar Thanks for offered help, you are very polite, but I am not allowed to share our project code. I have found that your But it doesn't work when a function component defined as a function, like this: function MyFunctionComponent(props) {
return <div>I am function component</div>;
}
MyFunctionComponent.propTypes = {
/**
* This is someProp
*/
someProp: PropTypes.string
} or like styled component const Absolute = styled('div')`
`
Absolute.propTypes = {
top: PropTypes.string
} it gives Warning: Cannot parse bar/foo/Foo.js: RangeError: Maximum call stack size exceeded |
@Heymdall, do you know about this problem? |
@stepancar We actually don't use this kind of components in our projects. But I will try to look into it today. |
@peroperje Don't know if you figured this out. Leaving for future wanderrs:
Reference: styled-components/styled-components#945 TL;DR: You'd have to use like this: const H1 = styled.h1`
font-size: 1.5em;
text-align: center;
`;
const Headline = props => <H1 {...props} />;
Heading.propTypes = {
top: PropTypes.string
} |
@siddharthkp we actually do support styled-components in styleguidist with |
Apparently there is an ongoing work to support this natively in react-docgen: reactjs/react-docgen#352 |
Try react-docgen-external-proptypes-handler and if it's good: create a repo, publish to npm, and add to Styleguidist by default.
More details about the issue: reactjs/react-docgen#33
Related issues: #548, #792
/cc @pasupuletics
The text was updated successfully, but these errors were encountered: