Browse Source

[docs] Revise marketing copy around JSX.

main
yungsters 12 years ago
parent
commit
6981a7e754
  1. 12
      _config.yml
  2. 22
      docs/syntax.md
  3. 30
      index.md

12
_config.yml

@ -1,14 +1,14 @@
--- ---
pygments: true
name: React name: React
markdown: redcarpet
baseurl: /react
react_version: 0.3.0 react_version: 0.3.0
redcarpet:
extensions:
- fenced_code_blocks
pygments: true
exclude: exclude:
- Gemfile - Gemfile
- Gemfile.lock - Gemfile.lock
- README.md - README.md
- Rakefile - Rakefile
redcarpet:
extensions:
- fenced_code_blocks
markdown: redcarpet
baseurl: /react

22
docs/syntax.md

@ -7,27 +7,25 @@ prev: common-questions.html
next: component-basics.html next: component-basics.html
--- ---
JSX is a JavaScript XML syntax extension recommended (but not required) for use JSX is a JavaScript XML syntax transform recommended (but not required) for use
with React. with React.
JSX makes code that deeply nests React components more readable, and writing it
feels like writing HTML. React documentation examples make use of JSX.
## Why JSX? ## Why JSX?
First of all, **don't use JSX if you don't like it!** All of React's features First of all, **don't use JSX if you don't like it!**
work just fine without using JSX. Simply construct your markup using the functions
on `React.DOM`. For example, here's how to construct a simple link: React works out of the box without JSX. Simply construct your markup using the
functions on `React.DOM`. For example, here's how to construct a simple link:
```javascript ```javascript
var mylink = React.DOM.a({href: 'http://facebook.github.io/react'}, 'Hello React'); var link = React.DOM.a({href: 'http://facebook.github.io/react'}, 'React');
``` ```
However, we like JSX for a bunch of reasons: We recommend using JSX for many reasons:
- It's easier to visualize the structure of the DOM - It's easier to visualize the structure of the DOM.
- Designers are more comfortable making changes - Designers are more comfortable making changes.
- It's familiar for those who have used MXML or XAML - It's familiar for those who have used MXML or XAML.
## The Transform ## The Transform

30
index.md

@ -3,19 +3,21 @@ layout: page
title: A JavaScript library for building user interfaces title: A JavaScript library for building user interfaces
id: home id: home
--- ---
<section class="light home-section"> <section class="light home-section">
<div class="marketing-row"> <div class="marketing-row">
<div class="marketing-col"> <div class="marketing-col">
<h3>The &quot;V&quot; in MVC</h3> <h3>Declarative</h3>
<p> <p>
Write reusable UI components in JavaScript. Read and write to any data source. React uses a declarative paradigm that makes it easier to reason about
your application.
</p> </p>
</div> </div>
<div class="marketing-col"> <div class="marketing-col">
<h3>Fast &amp; Declarative</h3> <h3>Efficient</h3>
<p> <p>
Describe how you want your component to look. React will automatically compute React computes the minimal set of changes necessary to keep your DOM
the fastest way to keep the UI up-to-date when the data changes. up-to-date.
</p> </p>
</div> </div>
<div class="marketing-col"> <div class="marketing-col">
@ -33,21 +35,21 @@ id: home
<h3>A Simple Component</h3> <h3>A Simple Component</h3>
<p> <p>
React components implement a `render()` method that takes input data and React components implement a `render()` method that takes input data and
returns what to display. This example constructs the component using an returns what to display. This example uses an XML-like syntax called
XML-like syntax called JSX, but <strong>JSX is optional; you don&apos;t JSX. Input data that is passed into the component can be accessed by
need to use it</strong>. Input data is passed to the component as XML `render()` via `this.props`.<br />
attributes, and `render()` accesses this data via `this.props`. <strong>JSX is optional and not required to use React.</strong>
</p> </p>
<div id="helloExample"></div> <div id="helloExample"></div>
</div> </div>
<div class="example"> <div class="example">
<h3>A Stateful Component</h3> <h3>A Stateful Component</h3>
<p> <p>
In addition to taking data from its creator (accessed via `this.props`), In addition to taking input data (accessed via `this.props`), a
a component can maintain internal state data (accessed via component can maintain internal state data (accessed via `this.state`).
`this.state`). When a component's state data changes, the rendered When a component's state data changes, the rendered markup will be
markup will be updated by re-invoking `render()`. <strong>This example updated by re-invoking `render()`.<br />
doesn&apos;t use JSX</strong>, but you could if you wanted to. <strong>This example demonstrates use of React without JSX.</strong>
</p> </p>
<div id="timerExample"></div> <div id="timerExample"></div>
</div> </div>

Loading…
Cancel
Save