PageRenderTime 52ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/docs/docs/getting-started.ja-JP.md

https://gitlab.com/orvi2014/react
Markdown | 116 lines | 86 code | 30 blank | 0 comment | 0 complexity | fbe04a827587ea8dc6d50525af803cf0 MD5 | raw file
  1. ---
  2. id: getting-started-ja-JP
  3. title: 始めてみましょう
  4. next: tutorial-ja-JP.html
  5. redirect_from: "docs/index-ja-JP.html"
  6. ---
  7. ## JSFiddle
  8. React でのハッキングを始めるにあたり一番簡単なものとして次の JSFiddle で動いている Hello World の例を取り上げます
  9. * **[React JSFiddle](https://jsfiddle.net/reactjs/69z2wepo/)**
  10. * [React JSFiddle without JSX](https://jsfiddle.net/reactjs/5vjqabv3/)
  11. ## スターターキット
  12. 始めるためにスターターキットをダウンロードしましょう
  13. <div class="buttons-unit downloads">
  14. <a href="/react/downloads/react-{{site.react_version}}.zip" class="button">
  15. Download Starter Kit {{site.react_version}}
  16. </a>
  17. </div>
  18. スターターキットのルートディレクトリに `helloworld.html` を作り次のように書いてみましょう
  19. ```html
  20. <!DOCTYPE html>
  21. <html>
  22. <head>
  23. <script src="build/react.js"></script>
  24. <script src="build/JSXTransformer.js"></script>
  25. </head>
  26. <body>
  27. <div id="example"></div>
  28. <script type="text/jsx">
  29. React.render(
  30. <h1>Hello, world!</h1>,
  31. document.getElementById('example')
  32. );
  33. </script>
  34. </body>
  35. </html>
  36. ```
  37. JavaScript の中に書かれた XML シンタックスは JSX と呼ばれるものですJSX の詳しいことについては [JSX syntax](/react/docs/jsx-in-depth.html) を読んでくださいここでは JSX から vanilla JavaScript への変換をブラウザ内で行わせるため先程のコードには `<script type="text/jsx">` と書いており加えて `JSXTransformer.js` を読み込ませています
  38. ### ファイルの分割
  39. React JSX コードは別ファイルに分離することができます 次のような `src/helloworld.js` を作ってみましょう
  40. ```javascript
  41. React.render(
  42. <h1>Hello, world!</h1>,
  43. document.getElementById('example')
  44. );
  45. ```
  46. それが終わったら`helloworld.js` への参照を `helloworld.html` に書き込みましょう
  47. ```html{10}
  48. <script type="text/jsx" src="src/helloworld.js"></script>
  49. ```
  50. ### オフラインでの変換
  51. まずはコマンドラインツールをインストールしましょう[npm](https://www.npmjs.com/) が必要です)。
  52. ```
  53. npm install -g react-tools
  54. ```
  55. インストールが終わったら先程書いた `src/helloworld.js` ファイルを生の JavaScript に変換してみましょう
  56. ```
  57. jsx --watch src/ build/
  58. ```
  59. すると`src/helloword.js` に変更を加えるごとに `build/helloworld.js` が自動で生成されるようになります
  60. ```javascript{2}
  61. React.render(
  62. React.createElement('h1', null, 'Hello, world!'),
  63. document.getElementById('example')
  64. );
  65. ```
  66. 最後に HTML ファイルを以下のように書き換えましょう
  67. ```html{6,10}
  68. <!DOCTYPE html>
  69. <html>
  70. <head>
  71. <title>Hello React!</title>
  72. <script src="build/react.js"></script>
  73. <!-- JSXTransformer は必要ありません! -->
  74. </head>
  75. <body>
  76. <div id="example"></div>
  77. <script src="build/helloworld.js"></script>
  78. </body>
  79. </html>
  80. ```
  81. ## CommonJS を使うには
  82. React [browserify](http://browserify.org/) や [webpack](https://webpack.github.io/)、または CommonJS 準拠の他のモジュールシステムと一緒に使いたい場合、 [`react` npm package](https://www.npmjs.com/package/react) を使ってみてください。また、`jsx` ビルドツールをパッケージングシステム(CommonJS に限らず)に導入することも非常に簡単です。
  83. ## 次にすること
  84. [チュートリアル](/react/docs/tutorial.html) スターターキットの `examples` ディレクトリに入っている他の例を読んでみてください
  85. また[ワークフローUIコンポーネントルーティングデータマネジメントなど](https://github.com/facebook/react/wiki/Complementary-Tools)の方面で貢献しているコミュニティの wiki もあります。
  86. 幸運を祈りますReact へようこそ