diff --git a/docs/02-displaying-data.md b/docs/02-displaying-data.md index a133e403..3f5983a3 100644 --- a/docs/02-displaying-data.md +++ b/docs/02-displaying-data.md @@ -79,7 +79,7 @@ We strongly believe that components are the right way to separate concerns rathe We've found that the best solution for this problem is to generate markup directly from the JavaScript code such that you can use all of the expressive power of a real programming language to build UIs. In order to make this easier, we've added a very simple, **optional** HTML-like syntax for the function calls that generate markup called JSX. -**JSX lets you write JavaScript function calls with HTML syntax.** To generate a link in React using pure JavaScript you'd write: `React.DOM.a({href: 'http://facebook.github.io/react/'}, 'Hello React!')`. With JSX this becomes `Hello React!`. We've found this has made building React apps easier and designers tend to prefer the syntax, but everyone has their own workflow, so **JSX is not required to use React.** +**JSX lets you write JavaScript function calls with HTML syntax.** To generate a link in React using pure JavaScript you'd write: `React.createElement('a', {href: 'http://facebook.github.io/react/'}, 'Hello React!')`. With JSX this becomes `Hello React!`. We've found this has made building React apps easier and designers tend to prefer the syntax, but everyone has their own workflow, so **JSX is not required to use React.** JSX is very small; the "hello, world" example above uses every feature of JSX. To learn more about it, see [JSX in depth](/react/docs/jsx-in-depth.html). Or see the transform in action in [our live JSX compiler](/react/jsx-compiler.html). diff --git a/docs/02-displaying-data.zh-CN.md b/docs/02-displaying-data.zh-CN.md index c05548ce..d964bfac 100644 --- a/docs/02-displaying-data.zh-CN.md +++ b/docs/02-displaying-data.zh-CN.md @@ -76,7 +76,7 @@ React 组件非常简单。你可以认为它们就是简单的函数,接受 ` 我们得出解决这个问题最好的方案是通过 JavaScript 直接生成模板,这样你就可以用一个真正语言的所有表达能力去构建用户界面。为了使这变得更简单,我们做了一个非常简单、**可选**类似 HTML 语法 ,通过函数调用即可生成模板的编译器,称为 JSX。 -**JSX 让你可以用 HTML 语法去写 JavaScript 函数调用** 为了在 React 生成一个链接,通过纯 JavaScript 你可以这么写: `React.DOM.a({href: 'http://facebook.github.io/react/'}, 'Hello React!')`。通过 JSX 这就变成了 `Hello React!`。我们发现这会使搭建 React 应用更加简单,设计师也偏向用这用语法,但是每个人可以有它们自己的工作流,所以**JSX 不是必须用的。** +**JSX 让你可以用 HTML 语法去写 JavaScript 函数调用** 为了在 React 生成一个链接,通过纯 JavaScript 你可以这么写: `React.createElement('a', {href: 'http://facebook.github.io/react/'}, 'Hello React!')`。通过 JSX 这就变成了 `Hello React!`。我们发现这会使搭建 React 应用更加简单,设计师也偏向用这用语法,但是每个人可以有它们自己的工作流,所以**JSX 不是必须用的。** JSX 非常小;上面“hello, world”的例子使用了 JSX 所有的特性。想要了解更多,请看 [深入理解 JSX](/react/docs/jsx-in-depth.html)。或者直接使用[在线 JSX 编译器](/react/jsx-compiler.html)观察变化过程。 diff --git a/docs/02.1-jsx-in-depth.md b/docs/02.1-jsx-in-depth.md index 93cf2731..f3411359 100644 --- a/docs/02.1-jsx-in-depth.md +++ b/docs/02.1-jsx-in-depth.md @@ -28,14 +28,14 @@ We recommend using JSX for many reasons: ## The Transform JSX transforms from an XML-like syntax into native JavaScript. XML elements and -attributes are transformed into function calls and objects, respectively. +attributes are transformed into arguments to `React.createElement`. ```javascript var Nav; // Input (JSX): var app = ; // Output (JS): -var app = Nav({color:"blue"}); +var app = React.createElement(Nav, {color:"blue"}); ``` Notice that in order to use ``, the `Nav` variable must be in scope. @@ -47,7 +47,7 @@ var Nav, Profile; // Input (JSX): var app = ; // Output (JS): -var app = Nav({color:"blue"}, Profile(null, "click")); +var app = React.createElement(Nav, {color:"blue"}, React.createElement(Profile, null, "click")); ``` Use the [JSX Compiler](/react/jsx-compiler.html) to try out JSX and see how it diff --git a/docs/getting-started.md b/docs/getting-started.md index 17bdcc53..f92ea04b 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -81,7 +81,7 @@ The file `build/helloworld.js` is autogenerated whenever you make a change. ```javascript{2} React.render( - React.DOM.h1(null, 'Hello, world!'), + React.createElement('h1', null, 'Hello, world!'), document.getElementById('example') ); ``` diff --git a/docs/getting-started.zh-CN.md b/docs/getting-started.zh-CN.md index 905d676c..4dc0f631 100644 --- a/docs/getting-started.zh-CN.md +++ b/docs/getting-started.zh-CN.md @@ -80,7 +80,7 @@ jsx --watch src/ build/ ```javascript{2} React.render( - React.DOM.h1(null, 'Hello, world!'), + React.createElement('h1', null, 'Hello, world!'), document.getElementById('example') ); ``` diff --git a/docs/ref-01-top-level-api.md b/docs/ref-01-top-level-api.md index 0e372797..46544c1f 100644 --- a/docs/ref-01-top-level-api.md +++ b/docs/ref-01-top-level-api.md @@ -93,7 +93,7 @@ Verifies the object is a React component descriptor. ### React.DOM -`React.DOM` provides all of the standard HTML tags needed to build a React app. You generally don't use it directly; instead, just include it as part of the `/** @jsx React.DOM */` docblock. +`React.DOM` provides convenience wrappers around `React.createElement` for DOM components. These should only be used when not using JSX. For example, `React.DOM.div(null, 'Hello World!')` ### React.PropTypes diff --git a/docs/tutorial.md b/docs/tutorial.md index d107eaff..fc66a5a5 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -90,14 +90,14 @@ The first thing you'll notice is the XML-ish syntax in your JavaScript. We have var CommentBox = React.createClass({displayName: 'CommentBox', render: function() { return ( - React.DOM.div({className: "commentBox"}, + React.createElement('div', {className: "commentBox"}, "Hello, world! I am a CommentBox." ) ); } }); React.render( - CommentBox(null), + React.createElement(CommentBox, null), document.getElementById('content') ); ``` @@ -158,7 +158,7 @@ var CommentBox = React.createClass({ }); ``` -Notice how we're mixing HTML tags and components we've built. HTML components are regular React components, just like the ones you define, with one difference. The JSX compiler will automatically rewrite HTML tags to "React.DOM.tagName" expressions and leave everything else alone. This is to prevent the pollution of the global namespace. +Notice how we're mixing HTML tags and components we've built. HTML components are regular React components, just like the ones you define, with one difference. The JSX compiler will automatically rewrite HTML tags to `React.createElement(tagName)` expressions and leave everything else alone. This is to prevent the pollution of the global namespace. ### Component Properties diff --git a/tips/03-if-else-in-JSX.md b/tips/03-if-else-in-JSX.md index 4fb25efe..15e2e938 100644 --- a/tips/03-if-else-in-JSX.md +++ b/tips/03-if-else-in-JSX.md @@ -14,7 +14,7 @@ next: self-closing-tag.html React.render(