一、ES6写法

class Counter extends React.Component {
constructor(props) {
super(props);
this.state = {count: props.initialCount};
}
// ...
}

二、非ES6写法:

var createReactClass = require('create-react-class');
var Counter = createReactClass({

getInitialState: function(){
return {count:this.props.initialCount}

},
render: function() {
return <h1>count: , {this.state.count}</h1>;
}
});