react-docgen icon indicating copy to clipboard operation
react-docgen copied to clipboard

How do we document methods inside a functional component?

Open VigneshSubramaniam opened this issue 4 years ago • 2 comments

Let's say I have a component like below:

/**
 *
 * This is geting documented
 */
function MyComponent(props) {
  /**
   *
   * This is not getting documented
   */
  const foo = () => {
    console.log('I am not documented :(');
  };
  return <div>Hello world!</div>;
}

the react-docgen return object does not have any methods and just shows an empty array. Is there a way to document these kind of methods?

VigneshSubramaniam avatar Jun 10 '21 08:06 VigneshSubramaniam

This is not yet possible. you can try using this resolver: https://github.com/Jmeyering/react-docgen-annotation-resolver

danez avatar Jun 10 '21 18:06 danez

I have the same problem, did you solve it?

chenzp1996 avatar Feb 27 '22 06:02 chenzp1996

This works in v6 if you annotated the component with @component:

/**
 * This is geting documented
 */
function MyComponent(props) {
  /**
   *
   * This is not getting documented
   * @component
   */
  const foo = () => {
    console.log('I am not documented :(');
  };
  return <div>Hello world!</div>;
}

danez avatar Apr 17 '23 20:04 danez