@shhhplus/react-timer
TypeScript icon, indicating that this package has built-in type declarations

2.0.3 • Public • Published

react-timer

GitHub license npm version codecov build status

This react timer component is very simple!

Install

npm install @shhhplus/react-timer --save

How to use

sync

import Timer from '@shhhplus/react-timer';

const Demo = () => {
  const onElapsed = () => {
    console.log('...');
  };
  return <Timer interval={1000} onElapsed={onElapsed} />;
};

async

import Timer from '@shhhplus/react-timer';

const Demo = () => {
  const onElapsed = () => {
    console.log('...');
    return new Promise((resolve) => {
      setTimeout(resolve, 100);
    });
  };
  return <Timer interval={1000} onElapsed={onElapsed} />;
};

Package Sidebar

Install

npm i @shhhplus/react-timer

Weekly Downloads

0

Version

2.0.3

License

MIT

Unpacked Size

3.46 kB

Total Files

5

Last publish

Collaborators

  • shhhplus