Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useCallback + useImperativeHandle methods #856

Open
mfazekas opened this issue Oct 6, 2023 · 0 comments
Open

useCallback + useImperativeHandle methods #856

mfazekas opened this issue Oct 6, 2023 · 0 comments
Labels

Comments

@mfazekas
Copy link
Contributor

mfazekas commented Oct 6, 2023

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": []
  }
]
@mfazekas mfazekas changed the title useCallback + useImperativeHandle in methods useCallback + useImperativeHandle methods Oct 6, 2023
@danez danez added the bug label Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants