No props data outputted for components typed with React.FC<>
Hi, I have a component that looks like this
interface Props {
a: string;
b: number;
}
const MyComponent: React.FC<Props> = (props) => {...}
export default MyComponent
When parsing props for this component I get no props output => require('react-docgen-typescript').parse(...) returns an empty array.
Changing to the following returns props as expected:
const MyComponentt = (props: Props) => {...}
Would it be possible to support the React.FC type assignment as well? That is my preferred way to type my functional components since it takes care of typing things like props.children correctly without an explicit field in the interface.
I have the same problem, whether we can support this way
I've run into the same problem in storybook attempting to create a guide for our customized react-bootstrap components. I've yet to discover a workaround.
Potentially related issues I found when trying to resolve this problem: https://github.com/storybookjs/storybook/issues/14118 https://github.com/styleguidist/react-docgen-typescript/issues/323
This is outside my domain of expertise but if a steward of this repo could point me to a good starting place I could make an attempt at a PR.
After poking around the repo a bit I've discovered several tests actually do use React.FC and are successful. #323 appears to be the culprit.
Yes. I can confirm this. I had the same issue and using this import * as React from 'react'; instead of import React from 'react'; works
Can confirm the solution @upalatucci provided worked for me. Thank you so much for finding that!
There was no activity for a long time. The issue will be closed soon.
Closing this issue as obsolete.