mocheng / react-and-redux

《深入浅出React和Redux》代码

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

第二章, 在子控件按钮回调时,直接传入变化值1或-1,逻辑简单很多?

XiaoYaoDaddy opened this issue · comments

  onClickIncrementButton() {
    this.updateCount(1);
  }

  onClickDecrementButton() {
    this.updateCount(-1);
  }

  updateCount(changeValue) {
    this.setState({count: this.state.count + changeValue})
    this.props.onUpdate(changeValue)
  }