Skip to content

Commit 2942338

Browse files
committed
Remove un-required logic in "startCountdown" method.
1 parent 6a54a1a commit 2942338

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,15 @@ export default class Countdown extends PureComponent {
9090
handleNetworkConnectivityChange = isConnected => this.setState({ isConnected });
9191

9292
startCountdown = () => {
93-
if (this.state.status === CountdownStatus.Counting) return;
94-
this.handlePress();
93+
const { onNetworkFailed } = this.props;
94+
const { status, isConnected } = this.state;
95+
if (status === CountdownStatus.Counting) return;
96+
97+
if (isConnected) {
98+
this.setState({ status: CountdownStatus.Counting }, this.startTimer);
99+
} else {
100+
onNetworkFailed && onNetworkFailed();
101+
}
95102
}
96103

97104
stopCountdown = () => {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rn-countdown",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"description": "A smart countdown component for react-native apps. You may use it to handle different status when request a verification code.",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)