react关于props和state举个例子

var Counter = React.createClass({
  getInitialState: function() {
    return {count: this.props.initialCount};
  },

  handleClick: function() {
    this.setState({count: this.state.count + 1});
  },

  render: function() {
    return <div onClick={this.handleClick}>{this.state.count}</div>;
  }
});

React.render(<Counter initialCount={7}/>, mountNode);
 
原文地址:https://www.cnblogs.com/wg-666/p/5403918.html