A React component to handle countdowns
npm install react-t-minus
import T from 'react-t-minus';
<T
minus={10}
onComplete={() => console.log('blast off!')}
onTick={({ secondsLeft }) => console.log(secondsLeft)}
>
{({ isComplete, secondsLeft }) =>
isComplete ? (
<img src="https://media.giphy.com/media/26xBEamXwaMSUbV72/giphy.gif" alt="rocket launch" />
) : (
<div>{secondsLeft} seconds until launch...</div>
)
}
</T>
Type: number
The number (in seconds) to countdown from.
Type: function()
The function to invoke when the countdown is complete.
Type: function({ secondsLeft: number })
The function to invoke per tick of the countdown. Also includes how many seconds are left (secondsLeft
).
Type: boolean
Returns whether or not the countdown is complete
Type: number
Returns the amount of seconds left
MIT © jxom