<div id="root"></div>
@import url(https://fonts.googleapis.com/css?family=Open+Sans);

body {
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}
button {
  vertical-align: middle;
  border-radius: 5px;
  padding: 15px 25px;
  font-size: 22px;
  text-decoration: none;
  margin: 20px;
  color: #fff;
  position: relative;
  display: inline-block;
  border: none 0;
  background-color: #55acee;
  box-shadow: 0px 5px 0px 0px #3C93D5;
}

button:active {
  transform: translate(0px, 5px);
  box-shadow: 0px 1px 0px 0px;
  outline: none;
}

button:hover {
  background-color: #6FC6FF;
  outline: none;
}

span {
  font-size: 3rem;
  display: inline-block;
  vertical-align: middle
}
View Compiled
class IncrementByObject extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      count: 0
    };
    this.increment = this.increment.bind(this);
  }
  
  // 此处设置调用两次 setState()
  increment() {
    this.setState({
      count: this.state.count + 1
    });
	
    this.setState({
      count: this.state.count + 1
    });
  }
  
  render() {
    return (
      <div>
        <button onClick={this.increment}>IncrementByObject</button>
        <span>{this.state.count}</span>
      </div>
    );
  }
}
ReactDOM.render(
  <IncrementByObject />,
  document.getElementById('root')
);
View Compiled

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/react/15.6.1/react.min.js
  2. https://cdnjs.cloudflare.com/ajax/libs/react/15.6.1/react-dom.min.js