Created
December 10, 2015 00:25
-
-
Save edinsoncs/3e04f053063d354e8459 to your computer and use it in GitHub Desktop.
Javascript Reactjs PropTypes
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 lag="es"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Reactjs Hello World</title> | |
<!-- Añadimos el framework Reactjs en nuestro html--> | |
</head> | |
<body> | |
<section id="main"></section> | |
<script src=" https://fb.me/react-0.13.3.js"></script> | |
<!-- Para compilar JSX creado por fb, añadimos jsxtransform--> | |
<script src="http://fb.me/JSXTransformer-0.13.3.js"></script> | |
<!-- Añadimos script con text/jsx paa que jsx transform lo entienda --> | |
<script type="text/jsx;harmony=true"> | |
//Creamos nuestro primer component | |
//Ojo para que funcione la primera debe ser mayuscula | |
var MiComponente = React.createClass({ | |
propTypes: { | |
name: React.PropTypes.string, | |
age: React.PropTypes.number | |
}, | |
render: function() { | |
return <h1>hola {this.props.name} tiene {this.props.age} Años</h1> | |
} | |
}) | |
React.render(<MiComponente name="Edinson" age={20} />, document.getElementById("main")); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment