Skip to content

Instantly share code, notes, and snippets.

@carlosdlf
Created April 30, 2015 19:47
Show Gist options
  • Save carlosdlf/6be561e682111ec66162 to your computer and use it in GitHub Desktop.
Save carlosdlf/6be561e682111ec66162 to your computer and use it in GitHub Desktop.
Widget Basic ReactJs
/**
* Created by clarico on 29/04/2015.
*/
var App = React.createClass({
getInitialState: function () {
return {
txt: ""
}
},
update: function (e) {
this.setState({txt: e.target.value});
},
render: function () {
return (
<div>
<Widget txt={this.state.txt} update={this.update}/>
<Widget txt={this.state.txt} update={this.update}/>
<Widget txt={this.state.txt} update={this.update}/>
<Widget txt={this.state.txt} update={this.update}/>
<Widget txt={this.state.txt} update={this.update}/>
</div>
);
}
});
var Widget = React.createClass({
render:function(){
return (
<div>
<input type="text" onChange={this.props.update} />
<br/>
<b>{this.props.txt}</b>
</div>
);
}
});
React.render(<App txt="Ingrese su nombre"/>, document.body);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment