Skip to content

Commit

Permalink
Invoke onComplete from start method instead of constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
bendikjohansen committed May 8, 2022
1 parent aec1472 commit b89e588
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Countdown.tsx
Expand Up @@ -124,9 +124,6 @@ export default class Countdown extends React.Component<CountdownProps, Countdown
timeDelta,
status: timeDelta.completed ? CountdownStatus.COMPLETED : CountdownStatus.STOPPED,
};
if (timeDelta.completed && props.onComplete) {
props.onComplete(timeDelta, true);
}
} else {
this.legacyMode = true;
}
Expand Down Expand Up @@ -197,6 +194,9 @@ export default class Countdown extends React.Component<CountdownProps, Countdown

const timeDelta = this.calcTimeDelta();
this.setTimeDeltaState(timeDelta, CountdownStatus.STARTED, this.props.onStart);
if (timeDelta.completed && this.props.onComplete) {
this.props.onComplete(timeDelta, true);
}

if (!this.props.controlled && (!timeDelta.completed || this.props.overtime)) {
this.clearTimer();
Expand Down

0 comments on commit b89e588

Please sign in to comment.