react-moment-countdown
An unopinionated countdown component for React using moment.js.
Installation
$ npm install react-moment-countdown --save
How to use
Date
instance into toDate
props:
Insert javascript ; ; { const dateInFuture = '2017-12-31'; return <ReactMomentCountDown toDate=dateInFuture /> ; };
moment
instance into toDate
props:
Insert ;;; { const dateInFuture = ; return <ReactMomentCountDown toDate=dateInFuture /> ;};
toDate
props with additional sourceFormatMask
props:
Insert string value into The default value of sourceFormatMask
props is YYYY-MM-DD
.
Customize
targetFormatMask
props
You can customize countdown format display with targetFormatMask
props (default is 'HH:mm:ss'
), for example
const sampleDate =
onTick
and onCountdownEnd
props
You can add onTick
function to trigger actions for every tick
and onCountdownEnd
to trigger actions when countdown timer has ended
{ superprops thisstate = endCountdown: false thissampleOnTick = thissampleOnTick thissampleOnCountdownEnd = thissampleOnCountdownEnd } { this } { console } { const dateInFuture = ; return <ReactMomentCountDown toDate=dateInFuture onTick=thissampleOnTick onCountdownEnd=thissampleOnCountdownEnd /> }
TO-DO
- Add unit test
- Add a Storybook for examples and UI tests