File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11{
22 "name" : " react-component-countdown-timer" ,
3- "version" : " 0.1.7 " ,
3+ "version" : " 0.1.8 " ,
44 "description" : " Count down timer component for react" ,
55 "main" : " lib/index.js" ,
66 "scripts" : {
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ export default class CountdownTimer extends Component {
2323 this . setState ( { count : newCount >= 0 ? newCount : 0 } , ( ) => {
2424 if ( this . state . count === 0 ) {
2525 this . props . onEnd ( ) ;
26+ clearInterval ( this . timer ) ;
2627 }
2728 } ) ;
2829 } , 1000 ) ;
@@ -56,10 +57,10 @@ export default class CountdownTimer extends Component {
5657 let minutes = Math . floor ( time / 60 ) % 60 ;
5758 let hours = Math . floor ( time / 3600 ) % 24 ;
5859 let day = Math . floor ( time / 86400 ) ;
59- day = day . toString ( ) . length === 1 ? `0${ day } ` : day ;
60- minutes = minutes . toString ( ) . length === 1 ? `0${ minutes } ` : minutes ;
61- seconds = seconds . toString ( ) . length === 1 ? `0${ seconds } ` : seconds ;
62- hours = hours . toString ( ) . length === 1 ? `0${ hours } ` : hours ;
60+ day = day < 10 ? `0${ day } ` : day ;
61+ minutes = minutes < 10 ? `0${ minutes } ` : minutes ;
62+ seconds = seconds < 10 ? `0${ seconds } ` : seconds ;
63+ hours = hours < 10 ? `0${ hours } ` : hours ;
6364 if ( showTitle ) {
6465 const borderClass = border ? 'border' : '' ;
6566 const responsiveClass = responsive ? 'responsive' : '' ;
You can’t perform that action at this time.
0 commit comments