From 6273d64359088c70063f757b3551de42ca4cb3cf Mon Sep 17 00:00:00 2001 From: gusbueno Date: Tue, 22 Oct 2019 13:51:11 +0200 Subject: [PATCH] better way to setstate avoiding side effects --- ch9/timer/index.ios.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ch9/timer/index.ios.js b/ch9/timer/index.ios.js index 7a44767..59495dc 100644 --- a/ch9/timer/index.ios.js +++ b/ch9/timer/index.ios.js @@ -26,7 +26,7 @@ var TimerWrapper = React.createClass({ toggleTime(){ let time = this.state.time if (time == 0 ) time = null - this.setState({isMinutes: !this.state.isMinutes, time: time}) + this.setState(state => ({ ...state, isMinutes: !this.state.isMinutes, time: time})) }, startTimer(time) { clearInterval(this.state.int)