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
isnull | undefined | false | Infinity
, it will never done and there will be no timer - When
ms
istrue | <0
, it is done immediately and there will be no timer