Last active
November 19, 2015 23:08
-
-
Save heyjohnmurray/b194fab3618d3607c1c4 to your computer and use it in GitHub Desktop.
This shows how a widget can call another widget
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var App = React.createClass({ | |
getInitialState: function() { | |
return { | |
text: 'this is initial state text', | |
}; | |
}, | |
// update is a custom function we've created | |
update: function(e) { | |
this.setState({text: e.target.value}); | |
}, | |
render: function() { | |
return ( | |
<div> | |
<Widget text={this.state.text} update={this.update} /> | |
<Widget text={this.state.text} update={this.update} /> | |
</div> | |
); | |
}, | |
}); | |
var Widget = React.createClass({ | |
render: function() { | |
return ( | |
<div> | |
<input type='text' onChange={this.props.update} /> | |
<h1>{this.props.text}</h1> | |
</div> | |
); | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment