react-docgen-typescript: Problem with functional components
Hi!
Unfortunately, I can’t use Styleguidist+DocGenTypescript for stateless functional components.
Example of working code (class component):
import * as React from 'react';
import * as styles from './Logo.styl';
export class Logo extends React.Component<any, any> {
render() {
return (
<span className={styles.logo} />
);
}
}
export default Logo;
Just refactor if to SFC:
import * as React from 'react';
import * as styles from './Logo.styl';
export const Logo = () =>
<span className={styles.logo} />;
export default Logo;
After that we got the error:
Error in ./src/components/common/Logo/Logo.tsx
Module build failed: TypeError: Cannot read property 'methods' of null
@ ./~/react-styleguidist/loaders/styleguide-loader.js!./~/react-styleguidist/lib/index.js 43:29-195
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 21
Sorry, I have same problem.
My component path:
src/components/modules/Hoge/index.tsxinside of a component
styleguide.config.jsIt is not reflected in styleguide well.
I’m actually seeing this problem still (with react-docgen-typescript 1.1.0), but have tested three different ways of exporting a stateless functional component, where the one I happened to be using is the one that didn’t work.
We were exporting components this way, which produces the same error mentioned earlier here:
These two ways seems to work fine:
and
I’m open to switching to the latter way (want to avoid having to specify on import), but am wondering if the first way is supposed to work.
Edit: I see now a newer issue where this is mentioned as a “well known” issue, so I’ll just use the latter method for now.
Doesnt seem to work for me. I am getting:
Ideally I would love to be able to do
I think most of the thinks mentioned here should be fixed by v1.2.0 or v.1.2.1 so I am closing this issue. If you still have problem also in v1.2.1 please create a new issue.
Could you try to defined the empty props for that component?