Created
April 30, 2015 03:40
-
-
Save carlosdlf/37b32fe1b9f052af0134 to your computer and use it in GitHub Desktop.
Jugando con propiedads
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
/** | |
* Created by clarico on 29/04/2015. | |
*/ | |
var App = React.createClass({ | |
getDefaultProps: function () { /*defaults*/ | |
return { | |
txt:'default :D', | |
cat: 404 | |
} | |
}, | |
propTypes:{ | |
txt:React.PropTypes.string, | |
cat:React.PropTypes.number.isRequired | |
}, | |
render:function(){ | |
var txt = this.props.txt; //se declara la propiedad | |
var cat = this.props.cat; | |
return ( | |
<div> | |
<b>{cat}</b> | |
<h1>{txt}</h1> | |
</div> | |
); | |
} | |
}); | |
React.render(<App/>, document.body); |
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
<!DOCTYPE html> | |
<html> | |
<head lang="en"> | |
<meta charset="UTF-8"> | |
<title></title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.12.2/react.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.12.2/JSXTransformer.js"></script> | |
<script type="text/jsx" src="app.js"></script> | |
</head> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment