React timer countdown hook with easy to use API .
npm install --save react-cool-timer
or
yarn add react-cool-timer
or
pnpm add react-cool-timer
import { useTimer } from "react-cool-timer";
export const App = () => {
const { timeLeft } = useTimer({
onEndReached: () => console.log("Reached end"),
timeInterval: 20,
});
return <div>Timeleft : {timeLeft}</div>;
};
Name | Type | Default | Description |
---|---|---|---|
onEndReached | () => void |
null |
Sets a function to run after timer ends |
timeInterval | number |
REQUIRED | Sets time interval in seconds |