mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Rebuild website
This commit is contained in:
@@ -410,7 +410,7 @@
|
||||
<h3><a class="anchor" name="using-master"></a>Using master <a class="hash-link" href="#using-master">#</a></h3>
|
||||
<p>We have instructions for building from <code>master</code> <a href="https://github.com/facebook/react">in our GitHub repository</a>. We build a tree of CommonJS modules under <code>build/modules</code> which you can drop into any environment or packaging tool that supports CommonJS.</p>
|
||||
<h2><a class="anchor" name="jsx"></a>JSX <a class="hash-link" href="#jsx">#</a></h2><h3><a class="anchor" name="in-browser-jsx-transform"></a>In-browser JSX Transform <a class="hash-link" href="#in-browser-jsx-transform">#</a></h3>
|
||||
<p>If you like using JSX, we provide an in-browser JSX transformer for development <a href="/react/downloads.html">on our download page</a>. Simply include a <code><script type="text/jsx"></code> tag to engage the JSX transformer.</p>
|
||||
<p>If you like using JSX, babel provides an <a href="http://babeljs.io/docs/usage/browser/">in-browser ES6 and JSX transformer for development</a> called browser.js that can be included from a <code>babel-core</code> npm release or from <a href="http://cdnjs.com/libraries/babel-core">CDNJS</a>. Include a <code><script type="text/babel"></code> tag to engage the JSX transformer.</p>
|
||||
|
||||
<blockquote>
|
||||
<p>Note:</p>
|
||||
@@ -418,12 +418,39 @@
|
||||
<p>The in-browser JSX transformer is fairly large and results in extraneous computation client-side that can be avoided. Do not use it in production — see the next section.</p>
|
||||
</blockquote>
|
||||
<h3><a class="anchor" name="productionizing-precompiled-jsx"></a>Productionizing: Precompiled JSX <a class="hash-link" href="#productionizing-precompiled-jsx">#</a></h3>
|
||||
<p>If you have <a href="https://www.npmjs.com/">npm</a>, you can simply run <code>npm install -g react-tools</code> to install our command-line <code>jsx</code> tool. This tool will translate files that use JSX syntax to plain JavaScript files that can run directly in the browser. It will also watch directories for you and automatically transform files when they are changed; for example: <code>jsx --watch src/ build/</code>.</p>
|
||||
<p>If you have <a href="https://www.npmjs.com/">npm</a>, you can run <code>npm install -g babel</code>. <code>babel</code> has built-in support for React v0.12 and v0.13. Tags are automatically transformed to their equivalent <code>React.createElement(...)</code>, <code>displayName</code> is automatically inferred and added to all React.createClass calls.</p>
|
||||
|
||||
<p>By default JSX files with a <code>.js</code> extension are transformed. Use <code>jsx --extension jsx src/ build/</code> to transform files with a <code>.jsx</code> extension.</p>
|
||||
<p>This tool will translate files that use JSX syntax to plain JavaScript files that can run directly in the browser. It will also watch directories for you and automatically transform files when they are changed; for example: <code>babel --watch src/ --out-dir lib/</code>.</p>
|
||||
|
||||
<p>Run <code>jsx --help</code> for more information on how to use this tool.</p>
|
||||
<h3><a class="anchor" name="helpful-open-source-projects"></a>Helpful Open-Source Projects <a class="hash-link" href="#helpful-open-source-projects">#</a></h3>
|
||||
<p>By default JSX files with a <code>.js</code> extension are transformed. Run <code>babel --help</code> for more information on how to use <code>babel</code>.</p>
|
||||
|
||||
<p>Example output:</p>
|
||||
<div class="highlight"><pre><code class="language-text" data-lang="text">$ cat test.jsx
|
||||
var HelloMessage = React.createClass({
|
||||
render: function() {
|
||||
return <div>Hello {this.props.name}</div>;
|
||||
}
|
||||
});
|
||||
|
||||
React.render(<HelloMessage name="John" />, mountNode);
|
||||
$ babel test.jsx
|
||||
"use strict";
|
||||
|
||||
var HelloMessage = React.createClass({
|
||||
displayName: "HelloMessage",
|
||||
|
||||
render: function render() {
|
||||
return React.createElement(
|
||||
"div",
|
||||
null,
|
||||
"Hello ",
|
||||
this.props.name
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
React.render(React.createElement(HelloMessage, { name: "John" }), mountNode);
|
||||
</code></pre></div><h3><a class="anchor" name="helpful-open-source-projects"></a>Helpful Open-Source Projects <a class="hash-link" href="#helpful-open-source-projects">#</a></h3>
|
||||
<p>The open-source community has built tools that integrate JSX with several editors and build systems. See <a href="https://github.com/facebook/react/wiki/Complementary-Tools#jsx-integrations">JSX integrations</a> for the full list.</p>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user