JSPM

react-hook-timeout

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q29039F
  • License MIT

A component of React Hook based on setTimeout and clearTimeout that supports multi-timeout management.

Package Exports

  • react-hook-timeout

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-hook-timeout) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

react-hook-timeout

A component of React Hook based on setTimeout and clearTimeout that supports multi-timeout management.

Install

Using npm

npm install react-hook-timeout --save-dev

Usage

ESM usage

import useTimeout from 'react-hook-timeout';

export default function myComponent() {
    const { setTimeout } = useTimeout();
    setTimeout(() => {
        //delay doing something after 5 seconds
    }, 5000);
}

Description

This hook component supports to remove all timeout automatically when component uninstalled.

Method

setTimeout(callback, delay)

  • callback => {Function} The callback function for the timeout response.(required)
  • delay => {Number} Delay time.(required)
  • return value => {Number} Timeout ID

clearTimeout(id)

  • id => {Number} Timeout ID.(required)

License

react-hook-timeout is MIT licensed.