File tree 2 files changed +6
-5
lines changed
2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " react-component-countdown-timer" ,
3
- "version" : " 0.1.7 " ,
3
+ "version" : " 0.1.8 " ,
4
4
"description" : " Count down timer component for react" ,
5
5
"main" : " lib/index.js" ,
6
6
"scripts" : {
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ export default class CountdownTimer extends Component {
23
23
this . setState ( { count : newCount >= 0 ? newCount : 0 } , ( ) => {
24
24
if ( this . state . count === 0 ) {
25
25
this . props . onEnd ( ) ;
26
+ clearInterval ( this . timer ) ;
26
27
}
27
28
} ) ;
28
29
} , 1000 ) ;
@@ -56,10 +57,10 @@ export default class CountdownTimer extends Component {
56
57
let minutes = Math . floor ( time / 60 ) % 60 ;
57
58
let hours = Math . floor ( time / 3600 ) % 24 ;
58
59
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 ;
63
64
if ( showTitle ) {
64
65
const borderClass = border ? 'border' : '' ;
65
66
const responsiveClass = responsive ? 'responsive' : '' ;
You can’t perform that action at this time.
0 commit comments