Function useDelayedCallback

Custom hook that returns a delayed callback function.

const delayedCallback = useDelayedCallback(1000);
delayedCallback(() => console.log('foo')); // This will log 'foo' after 1 second.
  • Parameters

    • delay: number

      The delay in milliseconds before the callback can be executed.

    Returns (callback: () => void) => false | void

    • A function that takes a callback to be executed after the delay.