@yao-react/use-timeout
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

@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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.0
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.0
    2

Package Sidebar

Install

npm i @yao-react/use-timeout

Weekly Downloads

2

Version

0.1.0

License

MIT

Unpacked Size

12.7 kB

Total Files

15

Last publish

Collaborators

  • zhaoyao91