strothj / react-docgen-typescript-loader

Webpack loader to generate docgen information from Typescript React components.
Other
360 stars 47 forks source link

Does not work with React memo. #56

Closed einaralex closed 5 years ago

einaralex commented 5 years ago

The propTypes section returns: "Unknown" Component No propTypes defined!

Example component:

import React, { SFC, memo } from 'react';

interface IProps {
  /**
   * This is the value
   */
  value: string;
}

export const Text: SFC<IProps> = memo(({ value }) => {
  return <div>{value}</div>;
});

export default Text;

Story:

import React from 'react';
import { storiesOf } from '@storybook/react';
import { withInfo } from '@storybook/addon-info';
import { Text } from '.';

storiesOf('Text', module).add('test component', withInfo({ inline: true })(() => <Text value="text" />));
einaralex commented 5 years ago

I got it work by wrapping the component in the default export.

export default memo(Text)