Make any DOM events handler more powerful and Specification with simple way
npm install --save react-use-countdown-timer
yarn add react-use-countdown-timer
import React from 'react';
import useCountdown from './useCountdown';
const App = () => {
const [ timer1 ] = useCountdown({ period: 10000 });
const [ timer2 ] = useCountdown({ period: 10000, gap: 500 });
const [ timer3 ] = useCountdown({ period: 10000, gap: 100 });
return (
<div style={{ padding: '20px', width: '100%' }}>
<h1>Test Use Coundown</h1>
<p>speed normal 1sec: {timer1 / 1000}</p>
<p>speed gap 500ms: {timer2 / 1000}</p>
<p>speed gap 100ms: {timer3 / 1000}</p>
</div>
);
};
export default App;
NOTE: React hooks require react
and react-dom
version 16.8.0
or higher.
- TypeScript
- add unit test
- add two commnad events onBlur and onFocus as default
This repo was setup with the help of the excellent create-react-library
and redux-react-hook
.
Zach Yu zachyu.tw@gmail.com
MIT © zachyutw