egoist
9/9/2015 - 2:28 PM

parent-child.js

var App = React.createClass({
  getInitialState: function () {
    return {
      name: 'I\'m Kevin, click me to change my name'
    }
  },
  handleClick: function () {
    this.setState({
      name: 'Peter is here now!'
    })
  },
  render: function () {
    return (
      <div onClick={this.handleClick}><Item name={this.state.name} /></div>
    )
  }
})

var Item = React.createClass({
  render: function () {
    return (
      <div>{this.props.name}</div>
    )
  }
})

React.render(<App />, document.body)