Created
September 19, 2015 19:01
-
-
Save carlosdiaz/b0483b08b64230a1d1f8 to your computer and use it in GitHub Desktop.
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 Hello = React.createClass({ | |
getInitialState : function(){ | |
return { dato1 : 'Marcos', dato2 : 1234}; | |
}, | |
render: function() { | |
setTimeout(function(){ this.setState( { dato1 : 'Carlos'}); }.bind(this),5000); | |
return <div>Hello {this.state.dato1}</div>; | |
} | |
}); | |
React.render(<Hello name="World" />, document.getElementById('container')); | |
React.render(<Hello name="World" />, document.getElementById('container1')); | |
//Second example | |
var Hello = React.createClass({ | |
getInitialState : function(){ | |
return { dato1 : 'Marcos', dato2 : 1234}; | |
}, | |
getDefaultProps : function() { | |
//se ejecuta solamente una vez | |
return {prop1: 'que tal', prop2: ''} | |
}, | |
render: function() { | |
//setTimeout(function(){ this.setState( { dato1 : 'Carlos'}); }.bind(this),5000); | |
return <div>Hello {this.props.prop1}</div>; | |
} | |
}); | |
React.render(<Hello prop1="Hola!!" />, document.getElementById('container')); | |
React.render(<Hello name="World" />, document.getElementById('container1')); | |
//Third example | |
var Hello = React.createClass({ | |
getInitialState : function(){ | |
return { dato1 : 'Marcos', dato2 : 1234}; | |
}, | |
getDefaultProps : function() { | |
//se ejecuta solamente una vez | |
return {prop1: 'que tal', prop2: ''} | |
}, | |
render: function() { | |
//setTimeout(function(){ this.setState( { dato1 : 'Carlos'}); }.bind(this),5000); | |
return <div>Hello {this.props.prop1}</div>; | |
} | |
}); | |
var unNombre = "Carlos Diaz" | |
React.render(<Hello prop1={unNombre} />, document.getElementById('container')); | |
React.render(<Hello name="World" />, document.getElementById('container1')); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment