Skip to content

Commit c195918

Browse files
committed
Fix prop change handling
1 parent 46aa953 commit c195918

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/index.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ class TimerWrapper extends Component {
2828
} = this.props;
2929

3030
if (active) {
31-
const progress = Math.max(0, Math.min(1, time / duration));
32-
3331
onStart({
3432
duration,
3533
progress: this.getProgress(time),
@@ -49,7 +47,7 @@ class TimerWrapper extends Component {
4947
onStop,
5048
} = nextProps;
5149

52-
if (active === this.props.active && time !== this.state.time) {
50+
if (active === this.props.active && time !== this.props.time && time !== this.state.time) {
5351
const timeDiff = this.state.time - time;
5452

5553
this.setState({
@@ -103,7 +101,7 @@ class TimerWrapper extends Component {
103101
} = this.state;
104102

105103
if (!duration) {
106-
return null;
104+
return 0;
107105
}
108106

109107
return Math.max(0, Math.min(1, time / duration));
@@ -125,15 +123,15 @@ class TimerWrapper extends Component {
125123

126124
let nextTime = Date.now() - startTime;
127125

128-
onTimeUpdate({
129-
duration,
130-
progress: this.getProgress(nextTime),
131-
time: nextTime,
132-
});
133-
134126
this.setState({
135127
time: nextTime,
136128
}, () => {
129+
onTimeUpdate({
130+
duration,
131+
progress: this.getProgress(nextTime),
132+
time: nextTime,
133+
});
134+
137135
if (duration !== null && nextTime >= duration) {
138136
onFinish({
139137
duration,

0 commit comments

Comments
 (0)