useTimeoutFn

A React Hook that helps to create a timeout function.

Demo

Source
isActive:
false

Usage

See API for more details.

Source

Click links below to view source on GitHub.

API

const pausable = useTimeoutFn(handler, interval, options)

Handler

A function to call when the timeout expires.

Interval

A number interval for the timeout in ms.

Options

export interface UseTimeoutFnOptions {
  /**
   * Start the timer immediate after calling this function
   *
   * @defaultValue true
   */
  immediate?: boolean
  /**
   * Render the component immediately when the timer ends
   *
   * When you need `isActive` ref to be updated immediately after the timer ends, set this to `true`
   *
   * @defaultValue false
   */
  updateOnEnd?: boolean
}

Returns

Retuerns contain Pausable instance that can be paused, resumed.

See Pausable for more details.

A Pausable instance.