0.1.0 • Published 5 years ago
@yao-react/use-timeout v0.1.0
@yao-react/use-timeout
React hook to treat timeout effect as state.
Philosophy
Effect as state.
Install
npm install @yao-react/use-timeoutyarn add @yao-react/use-timeoutGetting 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
msisnull | undefined | false | Infinity, it will never done and there will be no timer - When
msistrue | <0, it is done immediately and there will be no timer
0.1.0
5 years ago