JSPM

@yao-react/use-timeout

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q28360F
  • License MIT

React hook to treat timeout effect as state.

Package Exports

  • @yao-react/use-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 (@yao-react/use-timeout) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@yao-react/use-timeout

React hook to treat timeout effect as state.

Philosophy

Effect as state.

Install

npm install @yao-react/use-timeout
yarn add @yao-react/use-timeout

Getting started

import { useTimeout } from '@yao-react/use-timeout';

const Demo = () => {
  const done = useTimeout(1000);
  return <div>{done ? 'Done' : 'Not yet'}</div>;
};

API

prop type required description
ms null | undefined | boolean | number false the milliseconds to delay
deps Array false
  • When ms is null | undefined | false | Infinity, it will never done and there will be no timer
  • When ms is true | <0, it is done immediately and there will be no timer