ReactJS Owner Ownee

by Amanda Williamson

HTML

<script src="http://fb.me/JSXTransformer-0.12.1.js"></script>
<script src="http://fb.me/react-with-addons-0.12.1.js"></script>
<script src="http://facebook.github.io/react/js/jsfiddle-integration.js"></script>

JavaScript 1.7

var App = React.createClass({
    getInitialState: function(){
        return { txt:'', id: 0 }
    },
    updateTxt: function(e){
        this.setState({txt:e.target.value})
    },
    render:function(){
        return (
            <div>
                <Widget txt={this.state.txt} update={this.updateTxt} />
                <Widget txt={this.state.txt} update={this.updateTxt} />
                <Widget txt={this.state.txt} update={this.updateTxt} />
            </div>
        )
    }
});

var Widget = React.createClass({
    render: function(){
        return (
            <div>                
                <input type="text" onChange={this.props.update} />
                <h1>{this.props.txt}</h1>
            </div>
        )
    }
})

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