Created
February 24, 2015 05:42
-
-
Save ababup1192/83bb5753cf5e612e78cd to your computer and use it in GitHub Desktop.
React.js 公式ページ(http://facebook.github.io/react/index.html) なぞり
01 HelloWorld
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
// DOMを取得して、そこにXMLによる描画。JavaScriptの中にXMLをJSXと呼んでいるらしい。 | |
React.render( | |
<h1>Hello, world!</h1>, | |
document.getElementById('example') | |
); | |
// 別な描画を複数書いた場合は、最後のものが反映される。 | |
/* | |
React.render( | |
<h1>Hello, world2!</h1>, | |
document.getElementById('example') | |
); | |
*/ | |
// JSXを使わずに、jsで描画することも可能。 | |
// JSXを使わないため、「JSXTransformer.js」は読み込む必要がない。 | |
React.render( | |
React.createElement('h1', null, 'こんにちは、世界!'), | |
document.getElementById('example2') | |
); |
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> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.12.2/react-with-addons.min.js"></script> | |
<!-- JSXを扱うために必要 --> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.12.2/JSXTransformer.js"></script> | |
</head> | |
<body> | |
<div id="example"></div> | |
<div id="example2"></div> | |
<!-- JSXを含むjsのtypeは、text/jsxとなる。 --> | |
<script src="hello.js" type="text/jsx"></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment