reactjs/react-docgen

useCallback + useImperativeHandle methods

mfazekas opened this issue · 0 comments

Methods in the following component is not recognised. It works if I remove the useCallback.

import React, {
  forwardRef,
  memo,
  useCallback,
  useImperativeHandle,
  useMemo,
  useRef,
} from 'react';

export const MyComponent =
memo(forwardRef((_, ref) => {

  const _myMethod = useCallback((argument:string) : number => {});
  //const _myMethod = (argument:string) : number => {};
  
  useImperativeHandle(
    ref,
    () => ({
        /** myMethod description */
        _myMethod,
    }),
    [],
  );

  return <div />;
}));

return

[
  {
    "description": "",
    "displayName": "MyComponent",
    "methods": []
  }
]