useCallback() with typescript

PHOTO EMBED

Fri Apr 26 2024 06:10:02 GMT+0000 (Coordinated Universal Time)

Saved by @temp

const memoizedCallback = useCallback(
  (param1: string, param2: number) => {
    console.log(param1, param2)
    return { ok: true }
  },
  [...],
);
/**
 * VSCode will show the following type:
 * const memoizedCallback:
 *  (param1: string, param2: number) => { ok: boolean }
 */
content_copyCOPY

https://github.com/typescript-cheatsheets/react