Shadcn Hooks

useLockFn

A hook to lock a function until the previous promise is resolved

Installation

npx shadcn@latest add @shadcnhooks/use-lock-fn

API

/**
 * A hook to lock a function until the previous promise is resolved
 * @param fn - The function to lock
 * @returns The locked function
 */
export function useLockFn<P extends any[] = any[], V = any>(
  fn: (...args: P) => Promise<V>,
): (...args: P) => Promise<V | undefined>

Last updated on

On this page