Skip to content

Repository files navigation

react-timer

A minimalistic yet customizable timer component!

Live demo

Travis (.org) branchGitHub Release DatenpmNPMnpm bundle sizenpm bundle size

Basic Timer with 100ms interval

Installation

For NPM

npm install @xendora/react-timer

For Yarn

yarn add @xendora/react-timer

Usage

importReactTimerfrom"@xendora/react-timer";// Incremental counter<ReactTimerinterval={100}start={0}end={t=>t===100}onTick={t=>t+1}>{time=><span>{time}</span>}</ReactTimer>// Decremetal counter<ReactTimerinterval={100}start={100}end={t=>t===0}onTick={t=>t-1}>{time=><span>{time}</span>}</ReactTimer>
// Infinite counter
<ReactTimerinterval={100}start={0}end={t=>false}onTick={t=>t+1}>{time=><span>{time}</span>}</ReactTimer>

Props

NameTypeDescription
childrenobject (required)Define your react component here
startnumber (required)A start value for the timer
endfunction (required)A function which determines the end for the timer
intervalnumberAn interval value for the timer. Default is 1 second
onTickfunction (required)A callback function where the next computed value is determined
onEndfunctionA callback function which executes when the timer stops executing

License

MIT © xendora

Releases

Packages

Used by

Contributors

Languages