Compare commits
56 Commits
pr35331
...
0.4-stable
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
283f4a8b04 | ||
|
|
393a889aac | ||
|
|
3e455a4397 | ||
|
|
91b2ac57d4 | ||
|
|
c8996773ae | ||
|
|
a2a7536f38 | ||
|
|
ce478822e8 | ||
|
|
b88f97f9be | ||
|
|
ddbf91afd1 | ||
|
|
ae95674173 | ||
|
|
9e11fb626e | ||
|
|
ec746d3a1b | ||
|
|
91976ea8b4 | ||
|
|
9040c5f3a8 | ||
|
|
08d72df56b | ||
|
|
d6edc1189a | ||
|
|
6f532a839f | ||
|
|
34589c0e0d | ||
|
|
d91b238015 | ||
|
|
db904c2597 | ||
|
|
c12929700a | ||
|
|
30a11d2d7e | ||
|
|
a5115a2489 | ||
|
|
8b1990caa7 | ||
|
|
007d8b4f79 | ||
|
|
e6b5013a8b | ||
|
|
e4fa9ca9ee | ||
|
|
176ef3521c | ||
|
|
58635eea36 | ||
|
|
f8737dc8fe | ||
|
|
01297cf212 | ||
|
|
89437e6a97 | ||
|
|
ed755945a3 | ||
|
|
018e08cdd8 | ||
|
|
949c69fd56 | ||
|
|
a244928353 | ||
|
|
c034435052 | ||
|
|
8795a78ca0 | ||
|
|
123d091cc0 | ||
|
|
764ca84e02 | ||
|
|
3d78d30f49 | ||
|
|
fae1c48470 | ||
|
|
9801937715 | ||
|
|
0cac12d375 | ||
|
|
1e2d37f7e8 | ||
|
|
38bce710ac | ||
|
|
374c3b8a29 | ||
|
|
c362c16e1e | ||
|
|
fa5da5c848 | ||
|
|
734ee22a0c | ||
|
|
84dbb9bcd1 | ||
|
|
8ed80cae94 | ||
|
|
8b995ceb6a | ||
|
|
2e3594c8bc | ||
|
|
b2b9c690f8 | ||
|
|
7a760a5135 |
@@ -5,7 +5,7 @@ node_js:
|
||||
after_script:
|
||||
- curl -F "react=@build/react.js" -F "react.min=@build/react.min.js" -F "transformer=@build/JSXTransformer.js"
|
||||
-F "commit=$TRAVIS_COMMIT" -F "date=`git log --format='%ct' -1`" -F "pull_request=$TRAVIS_PULL_REQUEST"
|
||||
-F "token=$SECRET_TOKEN" $SERVER
|
||||
-F "token=$SECRET_TOKEN" -F "branch=$TRAVIS_BRANCH" $SERVER
|
||||
env:
|
||||
global:
|
||||
# SERVER
|
||||
|
||||
16
CHANGELOG.md
@@ -1,3 +1,19 @@
|
||||
## 0.4.1 (July 26, 2013)
|
||||
|
||||
### React
|
||||
|
||||
* `setState` callbacks are now executed in the scope of your component.
|
||||
* `click` events now work on Mobile Safari.
|
||||
* Prevent a potential error in event handling if `Object.prototype` is extended.
|
||||
* Don't set DOM attributes to the string `"undefined"` on update when previously defined.
|
||||
* Improved support for `<iframe>` attributes.
|
||||
* Added checksums to detect and correct cases where server-side rendering markup mismatches what React expects client-side.
|
||||
|
||||
### JSXTransformer
|
||||
|
||||
* Improved environment detection so it can be run in a non-browser environment.
|
||||
|
||||
|
||||
## 0.4.0 (July 17, 2013)
|
||||
|
||||
### React
|
||||
|
||||
@@ -32,16 +32,16 @@ You'll notice that we used an XML-like syntax; [we call it JSX](http://facebook.
|
||||
|
||||
## Installation
|
||||
|
||||
The fastest way to get started is to serve JavaScript from the CDN:
|
||||
The fastest way to get started is to serve JavaScript from the CDN (also available on [CDNJS](http://cdnjs.com/#react)):
|
||||
|
||||
```html
|
||||
<!-- The core React library -->
|
||||
<script src="http://fb.me/react-0.4.0.min.js"></script>
|
||||
<script src="http://fb.me/react-0.4.1.min.js"></script>
|
||||
<!-- In-browser JSX transformer, remove when pre-compiling JSX. -->
|
||||
<script src="http://fb.me/JSXTransformer-0.4.0.js"></script>
|
||||
<script src="http://fb.me/JSXTransformer-0.4.1.js"></script>
|
||||
```
|
||||
|
||||
We've also built a [starter kit](http://facebook.github.io/react/downloads/react-0.4.0.zip) which might be useful if this is your first time using React. It includes a webpage with an example of using React with live code.
|
||||
We've also built a [starter kit](http://facebook.github.io/react/downloads/react-0.4.1.zip) which might be useful if this is your first time using React. It includes a webpage with an example of using React with live code.
|
||||
|
||||
If you'd like to use [bower](http://bower.io), it's as easy as:
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gem 'rake'
|
||||
|
||||
# jekyll, which builds it all
|
||||
gem 'jekyll', '~>1.0'
|
||||
|
||||
@@ -14,3 +16,6 @@ gem 'rb-fsevent'
|
||||
|
||||
# Redcarpet for Markdown
|
||||
gem 'redcarpet'
|
||||
|
||||
# For markdown header cleanup
|
||||
gem 'sanitize'
|
||||
|
||||
@@ -24,13 +24,19 @@ GEM
|
||||
liquid (2.5.0)
|
||||
maruku (0.6.1)
|
||||
syntax (>= 1.0.0)
|
||||
mini_portile (0.5.1)
|
||||
nokogiri (1.6.0)
|
||||
mini_portile (~> 0.5.0)
|
||||
posix-spawn (0.3.6)
|
||||
pygments.rb (0.5.0)
|
||||
posix-spawn (~> 0.3.6)
|
||||
yajl-ruby (~> 1.1.0)
|
||||
rake (10.0.4)
|
||||
rb-fsevent (0.9.3)
|
||||
redcarpet (2.2.2)
|
||||
safe_yaml (0.7.1)
|
||||
sanitize (2.0.6)
|
||||
nokogiri (>= 1.4.4)
|
||||
sass (3.2.9)
|
||||
syntax (1.0.0)
|
||||
yajl-ruby (1.1.0)
|
||||
@@ -41,6 +47,8 @@ PLATFORMS
|
||||
DEPENDENCIES
|
||||
jekyll (~> 1.0)
|
||||
json
|
||||
rake
|
||||
rb-fsevent
|
||||
redcarpet
|
||||
sanitize
|
||||
sass
|
||||
|
||||
@@ -13,7 +13,7 @@ task :js do
|
||||
end
|
||||
|
||||
desc "watch css & js"
|
||||
task :watch => [:update_version] do
|
||||
task :watch do
|
||||
Process.spawn "sass --style=compressed --watch _css/react.scss:css/react.css"
|
||||
Process.spawn "../bin/jsx --watch _js js"
|
||||
Process.waitall
|
||||
@@ -30,8 +30,8 @@ task :update_version do
|
||||
end
|
||||
|
||||
desc "build into ../../react-gh-pages"
|
||||
task :release => [:default] do
|
||||
task :release => [:update_version, :default] do
|
||||
system "jekyll build -d ../../react-gh-pages"
|
||||
end
|
||||
|
||||
task :default => [:update_version, :css, :js]
|
||||
task :default => [:css, :js]
|
||||
|
||||
@@ -13,9 +13,11 @@ redcarpet:
|
||||
pygments: true
|
||||
name: React
|
||||
markdown: redcarpet
|
||||
react_version: 0.4.0
|
||||
react_version: 0.4.2
|
||||
description: A JavaScript library for building user interfaces
|
||||
relative_permalinks: true
|
||||
paginate: 5
|
||||
paginate_path: /blog/page:num
|
||||
nav_docs_sections:
|
||||
- title: Quick Start
|
||||
items:
|
||||
@@ -48,6 +50,20 @@ nav_docs_sections:
|
||||
- id: more-about-refs
|
||||
title: More About Refs
|
||||
- id: tooling-integration
|
||||
title: Tooling integration
|
||||
- id: reference
|
||||
title: Reference
|
||||
title: Tooling Integration
|
||||
- id: examples
|
||||
title: Examples
|
||||
- title: Reference
|
||||
items:
|
||||
- id: top-level-api
|
||||
title: Top-Level API
|
||||
- id: component-api
|
||||
title: Component API
|
||||
- id: component-specs
|
||||
title: Component Specs and Lifecycle
|
||||
- id: tags-and-attributes
|
||||
title: Supported Tags and Attributes
|
||||
- id: events
|
||||
title: Event System
|
||||
- id: dom-differences
|
||||
title: DOM Differences
|
||||
|
||||
@@ -199,8 +199,7 @@ li {
|
||||
font-size: 14px;
|
||||
// position: fixed;
|
||||
float: left;
|
||||
top: 100px;
|
||||
width: 180px;
|
||||
width: 210px;
|
||||
|
||||
ul {
|
||||
list-style: none;
|
||||
@@ -248,6 +247,12 @@ li {
|
||||
|
||||
}
|
||||
|
||||
.nav-blog {
|
||||
li {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
// Home Page specifics
|
||||
|
||||
.home-section {
|
||||
@@ -285,14 +290,14 @@ li {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
#examples {
|
||||
h3 {
|
||||
color: $darkColor;
|
||||
font-size: 24px;
|
||||
font-weight: normal;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
#examples h3, .home-presentation h3 {
|
||||
color: $darkColor;
|
||||
font-size: 24px;
|
||||
font-weight: normal;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
#examples {
|
||||
p {
|
||||
margin: 0 0 25px 0;
|
||||
max-width: $twoColumnWidth;
|
||||
@@ -685,3 +690,15 @@ p code {
|
||||
.post {
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.pagination {
|
||||
margin-bottom: 30px;
|
||||
|
||||
/* Trick to get the wrapper to expand to fit floating elements */
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
|
||||
.next {
|
||||
float: right;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
<div class="nav-docs">
|
||||
<div class="nav-docs nav-blog">
|
||||
<div class="nav-docs-section">
|
||||
<h3>Recent posts</h3>
|
||||
<ul>
|
||||
{% for post in site.posts %}
|
||||
<li><a href="/react{{ post.url }}"{% if page.title == post.title %} class="active"{% endif %}>{{ post.title }}</a></li>
|
||||
{% endfor %}
|
||||
{% for post in site.posts limit:10 %}
|
||||
<li><a href="/react{{ post.url }}"{% if page.title == post.title %} class="active"{% endif %}>{{ post.title }}</a></li>
|
||||
{% endfor %}
|
||||
<li><a href="/react/blog/all.html">All posts ...</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
<meta property="og:url" content="http://facebook.github.io/react{{ page.url }}" />
|
||||
<meta property="og:image" content="http://facebook.github.io/react/img/logo_og.png" />
|
||||
<meta property="og:description" content="A JavaScript library for building user interfaces" />
|
||||
<meta property="fb:app_id" content="623268441017527" />
|
||||
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="{{ site.name }}" href="{{ site.url }}{{ site.baseurl }}/feed.xml">
|
||||
|
||||
6
docs/_layouts/redirect.html
Normal file
@@ -0,0 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0; {{ page.destination }}">
|
||||
</head>
|
||||
<body></body>
|
||||
</html>
|
||||
17
docs/_plugins/header_links.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
require 'redcarpet'
|
||||
require 'sanitize'
|
||||
|
||||
# Simple converter that is probably better than RedCarpet's built in TOC id
|
||||
# generator (which ends up with things lik id="toc_1"... terrible).
|
||||
|
||||
class Redcarpet::Render::HTML
|
||||
def header(title, level)
|
||||
clean_title = Sanitize.clean(title)
|
||||
.downcase
|
||||
.gsub(/\s+/, "-")
|
||||
.gsub(/[^A-Za-z0-9\-_.]/, "")
|
||||
|
||||
return "<h#{level} id=\"#{clean_title}\">#{title}</h#{level}>"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -20,8 +20,8 @@ These templates dictate the full set of abstractions that you are allowed to use
|
||||
to build your UI.
|
||||
|
||||
React approaches building user interfaces differently by breaking them into
|
||||
**components**. This means React uses JavaScript to generate markup, which we
|
||||
see as an advantage over templates for a few reasons:
|
||||
**components**. This means React uses a real, full featured programming language
|
||||
to render views, which we see as an advantage over templates for a few reasons:
|
||||
|
||||
- **JavaScript is a flexible, powerful programming language** with the ability
|
||||
to build abstractions. This is incredibly important in large applications.
|
||||
|
||||
@@ -23,7 +23,7 @@ The best part is the demo of how React reconciliation process makes live editing
|
||||
|
||||
## React Snippets
|
||||
|
||||
Over the past several weeks, members of our team, [Pete Hunt](http://www.petehunt.net/) and [Paul O'Shannessy](http://zpao.com/), answered many questions that were asked in the [React group](https://groups.google.com/forum/#!forum/reactjs). They give a good overview of how to integrate React with other libraries and APIs through the use of [Mixins](/react/docs/mixins.html) and [Lifecycle Methods](/react/docs/advanced-components.html).
|
||||
Over the past several weeks, members of our team, [Pete Hunt](http://www.petehunt.net/) and [Paul O'Shannessy](http://zpao.com/), answered many questions that were asked in the [React group](https://groups.google.com/forum/#!forum/reactjs). They give a good overview of how to integrate React with other libraries and APIs through the use of [Mixins](/react/docs/reusable-components.html) and [Lifecycle Methods](/react/docs/working-with-the-browser.html).
|
||||
|
||||
> [Listening Scroll Event](https://groups.google.com/forum/#!topic/reactjs/l6PnP8qbofk)
|
||||
>
|
||||
|
||||
@@ -24,7 +24,7 @@ When you're ready, [go download it](/react/downloads.html)!
|
||||
* Removed `React.autoBind`. [Read our blog post for details...](http://facebook.github.io/react/blog/2013/07/02/react-v0-4-autobind-by-default.html)
|
||||
* Improvements to forms. We've written wrappers around `<input>`, `<textarea>`, `<option>`, and `<select>` in order to standardize many inconsistencies in browser implementations. This includes support for `defaultValue`, and improved implementation of the `onChange` event, and circuit completion. [Read the docs for details...](http://facebook.github.io/react/docs/forms.html)
|
||||
* We've implemented an improved synthetic event system that conforms to the W3C spec.
|
||||
* Updates to your component are batched now, which may result in a significantly faster re-render of components. `this.setState` now takes an optional callback as it's second parameter. If you were using `onClick={this.setState.bind(this, state)}` previously, you'll want to make sure you add a third parameter so that the event is not treated as the callback.
|
||||
* Updates to your component are batched now, which may result in a significantly faster re-render of components. `this.setState` now takes an optional callback as its second parameter. If you were using `onClick={this.setState.bind(this, state)}` previously, you'll want to make sure you add a third parameter so that the event is not treated as the callback.
|
||||
|
||||
### JSX
|
||||
|
||||
|
||||
@@ -96,4 +96,4 @@ React.renderComponent(
|
||||
> * [Working With the Browser](/react/docs/working-with-the-browser.html)
|
||||
> * [More About Refs](/react/docs/more-about-refs.html)
|
||||
> * [Tooling integration](/react/docs/tooling-integration.html)
|
||||
> * [Reference](/react/docs/reference.html)
|
||||
> * [Reference](/react/docs/top-level-api.html)
|
||||
|
||||
25
docs/_posts/2013-07-26-react-v0-4-1.md
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
title: "React v0.4.1"
|
||||
layout: post
|
||||
author: Paul O'Shannessy
|
||||
---
|
||||
|
||||
React v0.4.1 is a small update, mostly containing correctness fixes. Some code has been restructured internally but those changes do not impact any of our public APIs.
|
||||
|
||||
|
||||
## React
|
||||
|
||||
* `setState` callbacks are now executed in the scope of your component.
|
||||
* `click` events now work on Mobile Safari.
|
||||
* Prevent a potential error in event handling if `Object.prototype` is extended.
|
||||
* Don't set DOM attributes to the string `"undefined"` on update when previously defined.
|
||||
* Improved support for `<iframe>` attributes.
|
||||
* Added checksums to detect and correct cases where server-side rendering markup mismatches what React expects client-side.
|
||||
|
||||
|
||||
## JSXTransformer
|
||||
|
||||
* Improved environment detection so it can be run in a non-browser environment.
|
||||
|
||||
|
||||
[Download it now!](/react/downloads.html)
|
||||
54
docs/_posts/2013-07-30-use-react-and-jsx-in-ruby-on-rails.md
Normal file
@@ -0,0 +1,54 @@
|
||||
---
|
||||
title: "Use React and JSX in Ruby on Rails"
|
||||
layout: post
|
||||
author: Paul O'Shannessy
|
||||
---
|
||||
|
||||
Today we're releasing a gem to make it easier to use React and JSX in Ruby on Rails applications: [react-rails](https://github.com/facebook/react-rails).
|
||||
|
||||
|
||||
This gem has 2 primary purposes:
|
||||
|
||||
1. To package `react.js` in a way that's easy to use and easy to update.
|
||||
2. To allow you to write JSX without an external build step to transform that into JS.
|
||||
|
||||
|
||||
## Packaging react.js
|
||||
|
||||
To make `react.js` available for use client-side, simply add `react` to your manifest, and declare the variant you'd like to use in your environment. When you use `:production`, the minified and optimized `react.min.js` will be used instead of the development version. For example:
|
||||
|
||||
```ruby
|
||||
# config/environments/development.rb
|
||||
|
||||
MyApp::Application.configure do
|
||||
config.react.variant = :development
|
||||
# use :production in production.rb
|
||||
end
|
||||
```
|
||||
|
||||
```js
|
||||
// app/assets/javascript/application.js
|
||||
|
||||
//= require react
|
||||
```
|
||||
|
||||
|
||||
## Writing JSX
|
||||
|
||||
When you name your file with `myfile.js.jsx`, `react-rails` will automatically try to transform that file. For the time being, we still require that you include the docblock at the beginning of the file. For example, this file will get transformed on request.
|
||||
|
||||
```js
|
||||
/** @jsx React.DOM */
|
||||
React.renderComponent(<MyComponent/>, document.body)
|
||||
```
|
||||
|
||||
|
||||
## Asset Pipeline
|
||||
|
||||
`react-rails` takes advantage of the [asset pipeline](http://guides.rubyonrails.org/asset_pipeline.html) that was introduced in Rails 3.1. A very important part of that pipeline is the `assets:precompile` Rake task. `react-rails` will ensure that your JSX files will be transformed into regular JS before all of your assets are minified and packaged.
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
Installation follows the same process you're familiar with. You can install it globally with `gem install react-rails`, though we suggest you add the dependency to your `Gemfile` directly.
|
||||
|
||||
80
docs/_posts/2013-08-05-community-roundup-6.md
Normal file
@@ -0,0 +1,80 @@
|
||||
---
|
||||
title: "Community Round-up #6"
|
||||
layout: post
|
||||
author: Vjeux
|
||||
---
|
||||
|
||||
This is the first Community Round-up where none of the items are from Facebook/Instagram employees. It's great to see the adoption of React growing.
|
||||
|
||||
## React Game Tutorial
|
||||
|
||||
[Caleb Cassel](https://twitter.com/CalebCassel) wrote a [step-by-step tutorial](https://rawgithub.com/calebcassel/react-demo/master/part1.html) about making a small game. It covers JSX, State and Events, Embedded Components and Integration with Backbone.
|
||||
<figure>[](https://rawgithub.com/calebcassel/react-demo/master/part1.html)</figure>
|
||||
|
||||
|
||||
## Reactify
|
||||
|
||||
[Andrey Popp](http://andreypopp.com/) created a [Browserify](http://browserify.org/) helper to compile JSX files.
|
||||
|
||||
> Browserify v2 transform for `text/jsx`. Basic usage is:
|
||||
>
|
||||
> ```
|
||||
% browserify -t reactify main.jsx
|
||||
```
|
||||
>
|
||||
> `reactify` transform activates for files with either `.jsx` extension or `/** @jsx React.DOM */` pragma as a first line for any `.js` file.
|
||||
>
|
||||
> [Check it out on Github...](https://github.com/andreypopp/reactify)
|
||||
|
||||
|
||||
|
||||
## React Integration with Este
|
||||
|
||||
[Daniel Steigerwald](http://daniel.steigerwald.cz/) is now using React within [Este](https://github.com/steida/este), which is a development stack for web apps in CoffeeScript that are statically typed using the Closure Library.
|
||||
|
||||
```coffeescript
|
||||
este.demos.react.todoApp = este.react.create (`/** @lends {React.ReactComponent.prototype} */`)
|
||||
render: ->
|
||||
@div [
|
||||
este.demos.react.todoList 'items': @state['items']
|
||||
if @state['items'].length
|
||||
@p "#{@state['items'].length} items."
|
||||
@form 'onSubmit': @onFormSubmit, [
|
||||
@input
|
||||
'onChange': @onChange
|
||||
'value': @state['text']
|
||||
'autoFocus': true
|
||||
'ref': 'textInput'
|
||||
@button "Add ##{@state['items'].length + 1}"
|
||||
]
|
||||
]
|
||||
```
|
||||
|
||||
[Check it out on Github...](https://github.com/steida/este-library/blob/master/este/demos/thirdparty/react/start.coffee)
|
||||
|
||||
|
||||
## React Stylus Boilerplate
|
||||
|
||||
[Zaim Bakar](http://zaim.github.io/) shared his boilerplate to get started with Stylus CSS processor.
|
||||
|
||||
> This is my boilerplate React project using Grunt as the build tool, and Stylus as my CSS preprocessor.
|
||||
>
|
||||
> - Very minimal HTML boilerplate
|
||||
> - Uses Stylus, with nib included
|
||||
> - Uses two build targets:
|
||||
> - `grunt build` to compile JSX and Stylus into a development build
|
||||
> - `grunt dist` to minify and optimize the development build for production
|
||||
>
|
||||
> [Check it out on Github...](https://github.com/zaim/react-stylus-boilerplate)
|
||||
|
||||
|
||||
## WebFUI
|
||||
|
||||
[Conrad Barski](http://lisperati.com/), author of the popular book [Land of Lisp](http://landoflisp.com/), wants to use React for his ClojureScript library called [WebFUI](https://github.com/drcode/webfui).
|
||||
|
||||
> I'm the author of "[Land of Lisp](http://landoflisp.com/)" and I love your framework. I built a somewhat similar framework a year ago [WebFUI](https://github.com/drcode/webfui) aimed at ClojureScript. My framework also uses global event delegates, a global "render" function, DOM reconciliation, etc just like react.js. (Of course these ideas all have been floating around the ether for ages, always great to see more people building on them.)
|
||||
>
|
||||
> Your implementation is more robust, and so I think the next point release of webfui will simply delegate all the "hard work" to react.js and will only focus on the areas where it adds value (enabling purely functional UI programming in clojurescript, and some other stuff related to streamlining event handling)
|
||||
<figure>[](https://groups.google.com/forum/#!msg/reactjs/e3bYersyd64/qODfcuBR9LwJ)</figure>
|
||||
>
|
||||
> [Read the full post...](https://groups.google.com/forum/#!msg/reactjs/e3bYersyd64/qODfcuBR9LwJ)
|
||||
@@ -0,0 +1,56 @@
|
||||
---
|
||||
title: "Use React and JSX in Python Applications"
|
||||
layout: post
|
||||
author: Kunal Mehta
|
||||
---
|
||||
|
||||
Today we're happy to announce the initial release of [PyReact](https://github.com/facebook/react-python), which makes it easier to use React and JSX in your Python applications. It's designed to provide an API to transform your JSX files into JavaScript, as well as provide access to the latest React source files.
|
||||
|
||||
## Usage
|
||||
|
||||
Transform your JSX files via the provided `jsx` module:
|
||||
|
||||
```python
|
||||
from react import jsx
|
||||
|
||||
# For multiple paths, use the JSXTransformer class.
|
||||
transformer = jsx.JSXTransformer()
|
||||
for jsx_path, js_path in my_paths:
|
||||
transformer.transform(jsx_path, js_path)
|
||||
|
||||
# For a single file, you can use a shortcut method.
|
||||
jsx.transform('path/to/input/file.jsx', 'path/to/output/file.js')
|
||||
```
|
||||
|
||||
For full paths to React files, use the `source` module:
|
||||
|
||||
```python
|
||||
from react import source
|
||||
|
||||
# path_for raises IOError if the file doesn't exist.
|
||||
react_js = source.path_for('react.min.js')
|
||||
```
|
||||
|
||||
## Django
|
||||
|
||||
PyReact includes a JSX compiler for [django-pipeline](https://github.com/cyberdelia/django-pipeline). Add it to your project's pipeline settings like this:
|
||||
|
||||
```python
|
||||
PIPELINE_COMPILERS = (
|
||||
'react.utils.pipeline.JSXCompiler',
|
||||
)
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
PyReact is hosted on PyPI, and can be installed with `pip`:
|
||||
|
||||
$ pip install PyReact
|
||||
|
||||
Alternatively, add it into your `requirements` file:
|
||||
|
||||
PyReact==0.1.1
|
||||
|
||||
**Dependencies**: PyReact uses [PyExecJS](https://github.com/doloopwhile/PyExecJS) to execute the bundled React code, which requires that a JS runtime environment is installed on your machine. We don't explicitly set a dependency on a runtime environment; Mac OS X comes bundled with one. If you're on a different platform, we recommend [PyV8](https://code.google.com/p/pyv8/).
|
||||
|
||||
For the initial release, we've only tested on Python 2.7. Look out for support for Python 3 in the future, and if you see anything that can be improved, we welcome your [contributions](https://github.com/facebook/react-python/blob/master/CONTRIBUTING.md)!
|
||||
74
docs/_posts/2013-08-26-community-roundup-7.md
Normal file
@@ -0,0 +1,74 @@
|
||||
---
|
||||
title: "Community Round-up #7"
|
||||
layout: post
|
||||
author: Vjeux
|
||||
---
|
||||
|
||||
It's been three months since we open sourced React and it is going well. Some stats so far:
|
||||
|
||||
* 114 285 unique visitors on this website
|
||||
* [1933 stars](https://github.com/facebook/react/stargazers) and [210 forks](https://github.com/facebook/react/network/members)
|
||||
* [226 posts on Google Group](https://groups.google.com/forum/#!forum/reactjs)
|
||||
* [76 Github projects using React](https://gist.github.com/vjeux/6335762)
|
||||
* [30 contributors](https://github.com/facebook/react/graphs/contributors)
|
||||
* [15 blog posts](http://facebook.github.io/react/blog/)
|
||||
* 2 early adopters: [Khan Academy](http://benalpert.com/2013/06/09/using-react-to-speed-up-khan-academy.html) and [Propeller](http://usepropeller.com/blog/posts/from-backbone-to-react/)
|
||||
|
||||
|
||||
## Wolfenstein Rendering Engine Ported to React
|
||||
|
||||
[Pete Hunt](http://www.petehunt.net/) ported the render code of the web version of Wolfenstein 3D to React. Check out [the demo](http://www.petehunt.net/wolfenstein3D-react/wolf3d.html) and [render.js](https://github.com/petehunt/wolfenstein3D-react/blob/master/js/renderer.js#L183) file for the implementation.
|
||||
<figure>[](http://www.petehunt.net/wolfenstein3D-react/wolf3d.html)</figure>
|
||||
|
||||
|
||||
## React & Meteor
|
||||
|
||||
[Ben Newman](https://twitter.com/benjamn) made a [13-lines wrapper](https://github.com/benjamn/meteor-react/blob/master/lib/mixin.js) to use React and Meteor together. [Meteor](http://www.meteor.com/) handles the real-time data synchronization between client and server. React provides the declarative way to write the interface and only updates the parts of the UI that changed.
|
||||
|
||||
> This repository defines a Meteor package that automatically integrates the React rendering framework on both the client and the server, to complement or replace the default Handlebars templating system.
|
||||
>
|
||||
> The React core is officially agnostic about how you fetch and update your data, so it is far from obvious which approach is the best. This package provides one answer to that question (use Meteor!), and I hope you will find it a compelling combination.
|
||||
>
|
||||
>```javascript
|
||||
>var MyComponent = React.createClass({
|
||||
> mixins: [MeteorMixin],
|
||||
>
|
||||
> getMeteorState: function() {
|
||||
> return { foo: Session.get('foo') };
|
||||
> },
|
||||
>
|
||||
> render: function() {
|
||||
> return <div>{this.state.foo}</div>;
|
||||
> }
|
||||
>});
|
||||
>```
|
||||
>
|
||||
> Dependencies will be registered for any data accesses performed by getMeteorState so that the component can be automatically re-rendered whenever the data changes.
|
||||
>
|
||||
> [Read more ...](https://github.com/benjamn/meteor-react)
|
||||
|
||||
## React Page
|
||||
|
||||
[Jordan Walke](https://github.com/jordwalke) implemented a complete React project creator called [react-page](https://github.com/facebook/react-page/). It supports both server-side and client-side rendering, source transform and packaging JSX files using CommonJS modules, and instant reload.
|
||||
|
||||
> Easy Application Development with React JavaScript
|
||||
> <figure>[](https://github.com/facebook/react-page/)</figure>
|
||||
>
|
||||
> **Why Server Rendering?**
|
||||
>
|
||||
> * Faster initial page speed:
|
||||
> * Markup displayed before downloading large JavaScript.
|
||||
> * Markup can be generated more quickly on a fast server than low power client devices.
|
||||
> * Faster Development and Prototyping:
|
||||
> * Instantly refresh your app without waiting for any watch scripts or bundlers.
|
||||
> * Easy deployment of static content pages/blogs: just archive using recursive wget.
|
||||
> * SEO benefits of indexability and perf.
|
||||
>
|
||||
> **How Does Server Rendering Work?**
|
||||
>
|
||||
> * `react-page` computes page markup on the server, sends it to the client so the user can see it quickly.
|
||||
> * The corresponding JavaScript is then packaged and sent.
|
||||
> * The browser runs that JavaScript, so that all of the event handlers, interactions and update code will run seamlessly on top of the server generated markup.
|
||||
> * From the developer's (and the user's) perspective, it's just as if the rendering occurred on the client, only faster.
|
||||
>
|
||||
> [Try it out ...](https://github.com/facebook/react-page/)
|
||||
70
docs/_posts/2013-09-24-community-roundup-8.md
Normal file
@@ -0,0 +1,70 @@
|
||||
---
|
||||
title: "Community Round-up #8"
|
||||
layout: post
|
||||
author: Vjeux
|
||||
---
|
||||
|
||||
A lot has happened in the month since our last update. Here are some of the more interesting things we've found. But first, we have a couple updates before we share links.
|
||||
|
||||
First, we are organizing a [React Hackathon](http://reactjshack-a-thon.splashthat.com/) in Facebook's Seattle office on Saturday September 28. If you want to hack on React, meet some of the team or win some prizes, feel free to join us!
|
||||
|
||||
We've also reached a point where there are too many questions for us to handle directly. We're encouraging people to ask questions on [StackOverflow](http://stackoverflow.com/questions/tagged/reactjs) using the tag [[reactjs]](http://stackoverflow.com/questions/tagged/reactjs). Many members of the team and community have subscribed to the tag, so feel free to ask questions there. We think these will be more discoverable than Google Groups archives or IRC logs.
|
||||
|
||||
## Javascript Jabber
|
||||
|
||||
[Pete Hunt](http://www.petehunt.net/) and [Jordan Walke](https://github.com/jordwalke) were interviewed on [Javascript Jabber](http://javascriptjabber.com/073-jsj-react-with-pete-hunt-and-jordan-walke/) for an hour. They go over many aspects of React such as 60 FPS, Data binding, Performance, Diffing Algorithm, DOM Manipulation, Node.js support, server-side rendering, JSX, requestAnimationFrame and the community. This is a gold mine of information about React.
|
||||
|
||||
> **PETE:** So React was designed all around that. Conceptually, how you build a React app is that every time your data changes, it's like hitting the refresh button in a server-rendered app. What we do is we conceptually throw out all of the markup and event handlers that you've registered and we reset the whole page and then we redraw the entire page. If you're writing a server-rendered app, handling updates is really easy because you hit the refresh button and you're pretty much guaranteed to get what you expect.
|
||||
>
|
||||
> **MERRICK:** That's true. You don't get into these odd states.
|
||||
>
|
||||
> **PETE:** Exactly, exactly. In order to implement that, we communicate it as a fake DOM. What we'll do is rather than throw out the actual browser html and event handlers, we have an internal representation of what the page looks like and then we generate a brand new representation of what we want the page to look like. Then we perform this really, really fast diffing algorithm between those two page representations, DOM representations. Then React will compute the minimum set of DOM mutations it needs to make to bring the page up to date.
|
||||
>
|
||||
> Then to finally get to answer your question, that set of DOM mutations then goes into a queue and we can plug in arbitrary flushing strategies for that. For example, when we originally launched React in open source, every setState would immediately trigger a flush to the DOM. That wasn't part of the contract of setState, but that was just our strategy and it worked pretty well. Then this totally awesome open source contributor Ben Alpert at Khan Academy built a new batching strategy which would basically queue up every single DOM update and state change that happened within an event tick and would execute them in bulk at the end of the event tick.
|
||||
>
|
||||
> [Read the full conversation ...](http://javascriptjabber.com/073-jsj-react-with-pete-hunt-and-jordan-walke/)
|
||||
|
||||
|
||||
## JSXTransformer Trick
|
||||
|
||||
While this is not going to work for all the attributes since they are camelCased in React, this is a pretty cool trick.
|
||||
|
||||
<div style="margin-left: 74px;"><blockquote class="twitter-tweet"><p>Turn any DOM element into a React.js function: JSXTransformer.transform("/** <a href="https://twitter.com/jsx">@jsx</a> React.DOM */" + element.innerHTML).code</p>— Ross Allen (@ssorallen) <a href="https://twitter.com/ssorallen/statuses/377105575441489920">September 9, 2013</a></blockquote></div>
|
||||
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
|
||||
|
||||
|
||||
## Remarkable React
|
||||
|
||||
[Stoyan Stefanov](http://www.phpied.com/) gave a talk at [BrazilJS](http://braziljs.com.br/) about React and wrote an article with the content of the presentation. He goes through the difficulties of writting _active apps_ using the DOM API and shows how React handles it.
|
||||
|
||||
> So how does exactly React deal with it internally? Two crazy ideas - virtual DOM and synthetic events.
|
||||
>
|
||||
> You define you components in React. It builds a virtual DOM in JavaScript land which is way more efficient. Then it updates the DOM. (And "virtual DOM" is a very big name for what is simply a JavaScript object with nested key-value pairs)
|
||||
>
|
||||
> Data changes. React computes a diff (in JavaScript land, which is, of course, much more efficient) and updates the single table cell that needs to change. React replicates the state of the virtual DOM into the actual DOM only when and where it's necessary. And does it all at once, in most cases in a single tick of the `requestAnimationFrame()`.
|
||||
>
|
||||
> What about event handlers? They are synthetic. React uses event delegation to listen way at the top of the React tree. So removing a node in the virtual DOM has no effect on the event handling.
|
||||
>
|
||||
> The events are automatically cross-browser (they are React events). They are also much closer to W3C than any browser. That means that for example `e.target` works, no need to look for the event object or checking whether it's `e.target` or `e.srcElement` (IE). Bubbling and capturing phases also work cross browser. React also takes the liberty of making some small fixes, e.g. the event `<input onChange>` fires when you type, not when blur away from the input. And of course, event delegation is used as the most efficient way to handle events. You know that "thou shall use event delegation" is also commonly given advice for making web apps snappy.
|
||||
>
|
||||
> The good thing about the virtual DOM is that it's all in JavaScript land. You build all your UI in JavaScript. Which means it can be rendered on the server side, so you initial view is fast (and any SEO concerns are addressed). Also, if there are especially heavy operations they can be threaded into WebWorkers, which otherwise have no DOM access.
|
||||
>
|
||||
> [Read More ...](http://www.phpied.com/remarkable-react/)
|
||||
|
||||
|
||||
## Markdown in React
|
||||
|
||||
[Ben Alpert](http://benalpert.com/) converted [marked](https://github.com/chjj/marked), a Markdown Javascript implementation, in React: [marked-react](https://github.com/spicyj/marked-react). Even without using JSX, the HTML generation is now a lot cleaner. It is also safer as forgetting a call to `escape` will not introduce an XSS vulnerability.
|
||||
<figure>[](https://github.com/spicyj/marked-react/commit/cb70c9df6542c7c34ede9efe16f9b6580692a457)</figure>
|
||||
|
||||
|
||||
## Unite from BugBusters
|
||||
|
||||
[Renault John Lecoultre](https://twitter.com/renajohn) wrote [Unite](https://www.bugbuster.com/), an interactive tool for analyzing code dynamically using React. It integrates with CodeMirror.
|
||||
<figure>[](https://unite.bugbuster.com/)</figure>
|
||||
|
||||
## #reactjs IRC Logs
|
||||
|
||||
[Vjeux](http://blog.vjeux.com/) re-implemented the display part of the IRC logger in React. Just 130 lines are needed for a performant infinite scroll with timestamps and color-coded author names.
|
||||
|
||||
<iframe width="100%" height="300" src="http://jsfiddle.net/vjeux/QL9tz/embedded/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
|
||||
100
docs/_posts/2013-10-3-community-roundup-9.md
Normal file
@@ -0,0 +1,100 @@
|
||||
---
|
||||
title: "Community Round-up #9"
|
||||
layout: post
|
||||
author: Vjeux
|
||||
---
|
||||
|
||||
We organized a React hackathon last week-end in the Facebook Seattle office. 50 people, grouped into 15 teams, came to hack for a day on React. It was a lot of fun and we'll probably organize more in the future.
|
||||
|
||||

|
||||
|
||||
|
||||
## React Hackathon Winner
|
||||
|
||||
[Alex Swan](http://bold-it.com/) implemented [Qu.izti.me](http://qu.izti.me/), a multi-player quiz game. It is real-time via Web Socket and mobile friendly.
|
||||
|
||||
> The game itself is pretty simple. People join the "room" by going to [http://qu.izti.me](http://qu.izti.me/) on their device. Large displays will show a leaderboard along with the game, and small displays (such as phones) will act as personal gamepads. Users will see questions and a choice of answers. The faster you answer, the more points you earn.
|
||||
>
|
||||
> In my opinion, Socket.io and React go together like chocolate and peanut butter. The page was always an accurate representation of the game object.
|
||||
><figure>[](http://bold-it.com/javascript/facebook-react-example/)</figure>
|
||||
>
|
||||
> [Read More...](http://bold-it.com/javascript/facebook-react-example/)
|
||||
|
||||
## JSConf EU Talk: Rethinking Best Practices
|
||||
|
||||
[Pete Hunt](http://www.petehunt.net/) presented React at JSConf EU. He covers three controversial design decisions of React:
|
||||
|
||||
1. Build **components**, not templates
|
||||
2. Re-render the whole app on every update
|
||||
3. Virtual DOM
|
||||
|
||||
The video will be available soon on the [JSConf EU website](http://2013.jsconf.eu/speakers/pete-hunt-react-rethinking-best-practices.html), but in the meantime, here are Pete's slides:
|
||||
|
||||
<figure><iframe src="http://www.slideshare.net/slideshow/embed_code/26589373" width="550" height="450" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" allowfullscreen></iframe></figure>
|
||||
|
||||
|
||||
## Pump - Clojure bindings for React
|
||||
|
||||
[Alexander Solovyov](http://solovyov.net/) has been working on React bindings for ClojureScript. This is really exciting as it is using "native" ClojureScript data structures.
|
||||
|
||||
```ruby
|
||||
(ns your.app
|
||||
(:require-macros [pump.def-macros :refer [defr]])
|
||||
(:require [pump.core]))
|
||||
|
||||
(defr Component
|
||||
:get-initial-state #(identity {:some-value ""})
|
||||
|
||||
[component props state]
|
||||
|
||||
[:div {:class-name "test"} "hello"])
|
||||
```
|
||||
|
||||
[Check it out on GitHub...](https://github.com/piranha/pump)
|
||||
|
||||
|
||||
## JSXHint
|
||||
|
||||
[Todd Kennedy](http://blog.selfassembled.org/) working at [Condé Nast](http://www.condenast.com/) implemented a wrapper on-top of [JSHint](http://www.jshint.com/) that first converts JSX files to JS.
|
||||
|
||||
> A wrapper around JSHint to allow linting of files containg JSX syntax. Accepts glob patterns. Respects your local .jshintrc file and .gitignore to filter your glob patterns.
|
||||
>
|
||||
> ```
|
||||
npm install -g jsxhint
|
||||
```
|
||||
>
|
||||
> [Check it out on GitHub...](https://github.com/CondeNast/JSXHint)
|
||||
|
||||
|
||||
## Turbo React
|
||||
|
||||
[Ross Allen](https://twitter.com/ssorallen) working at [Mesosphere](http://mesosphere.io/) combined [Turbolinks](https://github.com/rails/turbolinks/), a library used by Ruby on Rails to speed up page transition, and React.
|
||||
|
||||
> "Re-request this page" is just a link to the current page. When you click it, Turbolinks intercepts the GET request and fetchs the full page via XHR.
|
||||
>
|
||||
> The panel is rendered with a random panel- class on each request, and the progress bar gets a random widthX class.
|
||||
>
|
||||
> With Turbolinks alone, the entire <body> would be replaced, and transitions would not happen. In this little demo though, React adds and removes classes and text, and the attribute changes are animated with CSS transitions. The DOM is otherwise left intact.
|
||||
><figure>[](https://turbo-react.herokuapp.com/)</figure>
|
||||
>
|
||||
> [Check out the demo...](https://turbo-react.herokuapp.com/)
|
||||
|
||||
|
||||
## Reactive Table
|
||||
|
||||
[Stoyan Stefanov](http://www.phpied.com/) continues his series of blog posts about React. This one is an introduction tutorial on rendering a simple table with React.
|
||||
|
||||
> React is all about components. So let's build one.
|
||||
>
|
||||
> Let's call it Table (to avoid any confusion what the component is about).
|
||||
>
|
||||
> ```javascript
|
||||
var Table = React.createClass({
|
||||
/*stuff goeth here*/
|
||||
});
|
||||
```
|
||||
>
|
||||
> You see that React components are defined using a regular JS object. Some properties and methods of the object such as render() have special meanings, the rest is upforgrabs.
|
||||
>
|
||||
> [Read the full article...](http://www.phpied.com/reactive-table/)
|
||||
|
||||
15
docs/blog/all.html
Normal file
@@ -0,0 +1,15 @@
|
||||
---
|
||||
title: Blog
|
||||
layout: default
|
||||
sectionid: blog
|
||||
id: all-posts
|
||||
---
|
||||
|
||||
<section class="content wrap documentationContent nosidebar">
|
||||
<div class="inner-content">
|
||||
<h1>All Posts</h1>
|
||||
{% for page in site.posts %}
|
||||
<p><strong><a href="/react{{ page.url }}">{{ page.title }}</a></strong> on {{ page.date | date: "%B %e, %Y" }} by {{ page.author }}</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</section>
|
||||
@@ -7,22 +7,28 @@ sectionid: blog
|
||||
<section class="content wrap blogContent">
|
||||
{% include nav_blog.html %}
|
||||
<div class="inner-content">
|
||||
{% for page in site.posts %}
|
||||
{% for page in paginator.posts %}
|
||||
<div class="post-list-item">
|
||||
<h1><a href="/react{{ page.url }}">{{ page.title }}</a></h1>
|
||||
<p class="meta">{{ page.date | date: "%B %e, %Y" }} by {{ page.author }}</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<hr />
|
||||
<div class="post">
|
||||
{{ page.excerpt }}
|
||||
{% if page.excerpt != page.content %}
|
||||
<p>
|
||||
<a href="/react{{ page.url }}">Continue Reading →</a>
|
||||
</p>
|
||||
{% endif %}
|
||||
{{ page.content }}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<div class="pagination">
|
||||
{% if paginator.previous_page %}
|
||||
<a href="/react/blog/{{ paginator.previous_page_path }}" class="previous">
|
||||
« Previous Page
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if paginator.next_page %}
|
||||
<a href="/react/blog/{{ paginator.next_page_path }}" class="next">
|
||||
Next Page »
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -82,7 +82,7 @@ var div = React.DOM.div;
|
||||
var app = <div className="appClass">Hello, React!</div>;
|
||||
```
|
||||
|
||||
### React Component Components
|
||||
### React Composite Components
|
||||
|
||||
To construct an instance of a composite component, create a variable that
|
||||
references the class.
|
||||
@@ -92,7 +92,7 @@ var MyComponent = React.createClass({/*...*/});
|
||||
var app = <MyComponent someProperty={true} />;
|
||||
```
|
||||
|
||||
See [Component Basics](component-basics.html) to learn more about components.
|
||||
See [Multiple Components](multiple-components.html) to learn more about using composite components.
|
||||
|
||||
> Note:
|
||||
>
|
||||
@@ -162,10 +162,15 @@ var content = <Container>{/* this is a comment */}<Nav /></Container>;
|
||||
Beyond the compilation step, JSX does not require any special tools.
|
||||
|
||||
* Many editors already include reasonable support for JSX (Vim, Emacs js2-mode).
|
||||
* JSX syntax highlighting is available for Sublime Text and other editors
|
||||
that support `*.tmLanguage` using the third-party
|
||||
[`JavaScript (JSX).tmLanguage`][1].
|
||||
* Linting provides accurate line numbers after compiling without sourcemaps.
|
||||
* Elements use standard scoping so linters can find usage of out-of-scope
|
||||
components.
|
||||
|
||||
[1]: https://github.com/yungsters/sublime/blob/master/tmLanguage/JavaScript%20(JSX).tmLanguage
|
||||
|
||||
## Prior Work
|
||||
|
||||
JSX is similar to several other JavaScript embedded XML language
|
||||
|
||||
@@ -144,7 +144,7 @@ In React, data flows from owner to owned component through `props` as discussed
|
||||
|
||||
You may be thinking that it's expensive to react to changing data if there are a large number of nodes under an owner. The good news is that JavaScript is fast and `render()` methods tend to be quite simple, so in most applications this is extremely fast. Additionally, the bottleneck is almost always the DOM mutation and not JS execution and React will optimize this for you using batching and change detection.
|
||||
|
||||
However, sometimes you really want to have fine-grained control over your performance. In that case, simply override `shouldComponentUpdate()` to return false when you want React to skip processing of a subtree. See [the React reference docs](./reference.html) for more information.
|
||||
However, sometimes you really want to have fine-grained control over your performance. In that case, simply override `shouldComponentUpdate()` to return false when you want React to skip processing of a subtree. See [the React reference docs](component-specs.html) for more information.
|
||||
|
||||
> Note:
|
||||
>
|
||||
|
||||
@@ -119,14 +119,16 @@ In addition to that philosophy, we've also taken the stance that we, as authors
|
||||
|
||||
### Polyfills Needed to Support Older Browsers
|
||||
|
||||
These six functions can be polyfilled using `es5-shim.js` from [kriskowal's es5-shim](https://github.com/kriskowal/es5-shim):
|
||||
|
||||
* `Array.isArray`
|
||||
* `Array.prototype.forEach`
|
||||
* `Array.prototype.indexOf`
|
||||
* `Function.prototype.bind`
|
||||
* `Array.prototype.some`
|
||||
* `Date.now`
|
||||
* `Array.prototype.some` (also in `es5-shim.js`)
|
||||
* `Function.prototype.bind`
|
||||
|
||||
All of these can be polyfilled using `es5-shim.js` from [https://github.com/kriskowal/es5-shim](https://github.com/kriskowal/es5-shim).
|
||||
Other required polyfills:
|
||||
|
||||
* `console.*` - Only needed when not using the minified build. If you need to polyfill this, try [https://github.com/paulmillr/console-polyfill](https://github.com/paulmillr/console-polyfill).
|
||||
* `Object.create` - Provided in `es5-sham.js` @ [https://github.com/kriskowal/es5-shim](https://github.com/kriskowal/es5-shim).
|
||||
* `Object.create` – Provided by `es5-sham.js` from [kriskowal's es5-shim](https://github.com/kriskowal/es5-shim).
|
||||
* `console.*` – Only needed when using the unminified build. If you need to polyfill this, try [paulmillr's console-polyfill](https://github.com/paulmillr/console-polyfill).
|
||||
|
||||
@@ -39,7 +39,7 @@ Consider the case when you wish to tell an `<input />` element (that exists with
|
||||
```
|
||||
|
||||
|
||||
Notice how, in this example, we want to "tell" the input something - something that it cannot infer from it's props over time. In this case we want to "tell" it that it should now become focused. However, there are some challenges. What is returned from `render()`` is not your actual composition of "child" components, it is merely a *description* of the children at a particular instance in time - a snapshot, if you will.
|
||||
Notice how, in this example, we want to "tell" the input something - something that it cannot infer from its props over time. In this case we want to "tell" it that it should now become focused. However, there are some challenges. What is returned from `render()` is not your actual composition of "child" components, it is merely a *description* of the children at a particular instance in time - a snapshot, if you will.
|
||||
|
||||
> Note:
|
||||
>
|
||||
|
||||
@@ -1,26 +1,28 @@
|
||||
---
|
||||
id: tooling-integration
|
||||
title: Tooling integration
|
||||
title: Tooling Integration
|
||||
layout: docs
|
||||
permalink: tooling-integration.html
|
||||
prev: more-about-refs.html
|
||||
next: reference.html
|
||||
next: examples.html
|
||||
---
|
||||
|
||||
Every project uses a different system for building and deploying JavaScript. We've tried to make React as environment-agnostic as possible.
|
||||
|
||||
## React
|
||||
|
||||
## CDN-hosted React
|
||||
### CDN-hosted React
|
||||
|
||||
We provide CDN-hosted versions of React [on our download page](/react/downloads.html). These prebuilt files use the UMD module format. Dropping them in with a simple `<script>` tag will inject a `React` global into your environment. It should also work out-of-the-box in CommonJS and AMD environments.
|
||||
|
||||
|
||||
## Using master
|
||||
### Using master
|
||||
|
||||
We have instructions for building from `master` [in our GitHub repository](https://github.com/facebook/react). We build a tree of CommonJS modules under `build/modules` which you can drop into any environment or packaging tool that supports CommonJS.
|
||||
|
||||
## JSX
|
||||
|
||||
## In-browser JSX Transform
|
||||
### In-browser JSX Transform
|
||||
|
||||
If you like using JSX, we provide an in-browser JSX transformer for development [on our download page](/react/downloads.html). Simply include a `<script type="text/jsx">` tag to engage the JSX transformer. Be sure to include the `/** @jsx React.DOM */` comment as well, otherwise the transformer will not run the transforms.
|
||||
|
||||
@@ -29,16 +31,22 @@ If you like using JSX, we provide an in-browser JSX transformer for development
|
||||
> 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.
|
||||
|
||||
|
||||
## Productionizing: Precompiled JSX
|
||||
### Productionizing: Precompiled JSX
|
||||
|
||||
If you have [npm](http://npmjs.org/), you can simply run `npm install -g react-tools` to install our command-line `jsx` 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: `jsx --watch src/ build/`. Run `jsx --help` for more information on how to use this tool.
|
||||
|
||||
|
||||
## Helpful Open-Source Projects
|
||||
### Helpful Open-Source Projects
|
||||
|
||||
The open-source community has built tools that integrate JSX with several build systems.
|
||||
|
||||
* [reactify](https://github.com/andreypopp/reactify) - use JSX with [browserify](http://browserify.org/).
|
||||
* [reactify](https://github.com/andreypopp/reactify) - use JSX with [browserify](http://browserify.org/)
|
||||
* [grunt-react](https://github.com/ericclemmons/grunt-react) - [grunt](http://gruntjs.com/) task for JSX
|
||||
* [require-jsx](https://github.com/seiffert/require-jsx) - use JSX with [require.js](http://requirejs.org/)
|
||||
* [reactapp](https://github.com/jordwalke/reactapp) - a sample project to get up-and-running with React quickly
|
||||
* [pyReact](https://github.com/facebook/react-python) - use JSX with [Python](http://www.python.org/)
|
||||
* [react-rails](https://github.com/facebook/react-rails) - use JSX with [Ruby on Rails](http://rubyonrails.org/)
|
||||
|
||||
|
||||
## React Page
|
||||
|
||||
To get started on a new project, you can use [react-page](https://github.com/facebook/react-page/), a complete React project creator. It supports both server-side and client-side rendering, source transform and packaging JSX files using CommonJS modules, and instant reload.
|
||||
|
||||
22
docs/docs/09-examples.md
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
id: examples
|
||||
title: Examples
|
||||
layout: docs
|
||||
permalink: examples.html
|
||||
prev: tooling-integration.html
|
||||
---
|
||||
|
||||
### Production Apps
|
||||
|
||||
* All of [Instagram.com](http://instagram.com/) is built on React.
|
||||
* Many components on [Facebook.com](http://www.facebook.com/), including the commenting interface, ads creation flows, and page insights.
|
||||
* [Khan Academy](http://khanacademy.org/) is using React for its question editor.
|
||||
|
||||
|
||||
### Sample Code
|
||||
|
||||
* We've included [a step-by-step comment box tutorial](./tutorial.html).
|
||||
* [The React starter kit](/react/downloads.html) includes several examples which you can [view online in our GitHub repository](https://github.com/facebook/react/tree/master/examples/).
|
||||
* [React Page](https://github.com/facebook/react-page) is a simple React project creator to get you up-and-running quickly with React. It supports both server-side and client-side rendering, source transform and packaging JSX files using CommonJS modules, and instant reload.
|
||||
* [React one-hour email](https://github.com/petehunt/react-one-hour-email/commits/master) goes step-by-step from a static HTML mock to an interactive email reader (written in just one hour!)
|
||||
* [Rendr + React app template](https://github.com/petehunt/rendr-react-template/) demonstrates how to use React's server rendering capabilities.
|
||||
@@ -1,209 +0,0 @@
|
||||
---
|
||||
id: reference
|
||||
title: Reference
|
||||
layout: docs
|
||||
permalink: reference.html
|
||||
prev: tooling-integration.html
|
||||
---
|
||||
|
||||
## Examples
|
||||
|
||||
|
||||
### Production Apps
|
||||
|
||||
* All of [Instagram.com](http://instagram.com/) is built on React.
|
||||
* Many components on [Facebook.com](http://www.facebook.com/), including the commenting interface, ads creation flows, and page insights.
|
||||
* [Khan Academy](http://khanacademy.org/) is using React for its question editor.
|
||||
|
||||
|
||||
### Sample Code
|
||||
|
||||
* We've included [a step-by-step comment box tutorial](./tutorial.html).
|
||||
* [The React starter kit](/react/downloads.html) includes several examples which you can [view online in our GitHub repository](https://github.com/facebook/react/tree/master/examples/).
|
||||
* [reactapp](https://github.com/jordwalke/reactapp) is a simple app template to get you up-and-running quickly with React.
|
||||
* [React one-hour email](https://github.com/petehunt/react-one-hour-email/commits/master) goes step-by-step from a static HTML mock to an interactive email reader (written in just one hour!)
|
||||
* [Rendr + React app template](https://github.com/petehunt/rendr-react-template/) demonstrates how to use React's server rendering capabilities.
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### React
|
||||
|
||||
`React` is the entry point to the React framework. If you're using one of the prebuilt packages it's available as a global; if you're using CommonJS modules you can `require()` it.
|
||||
|
||||
|
||||
#### 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.initializeTouchEvents
|
||||
|
||||
```javascript
|
||||
initializeTouchEvents(boolean shouldUseTouch)
|
||||
```
|
||||
|
||||
Configure React's event system to handle touch events on mobile devices.
|
||||
|
||||
|
||||
#### React.createClass
|
||||
|
||||
```javascript
|
||||
function createClass(object specification)
|
||||
```
|
||||
|
||||
Creates a component given a specification. A component implements a `render` method which returns **one single** child. That child may have an arbitrarily deep child structure. One thing that makes components different than standard prototypal classes is that you don't need to call new on them. They are convenience wrappers that construct backing instances (via new) for you.
|
||||
|
||||
|
||||
#### React.renderComponent
|
||||
|
||||
```javascript
|
||||
ReactComponent renderComponent(ReactComponent container, DOMElement container)
|
||||
```
|
||||
|
||||
Renders a React component into the DOM in the supplied `container`.
|
||||
|
||||
If the React component was previously rendered into `container`, this will perform an update on it and only mutate the DOM as necessary to reflect the latest React component.
|
||||
|
||||
|
||||
#### React.unmountAndReleaseReactRootNode
|
||||
|
||||
```javascript
|
||||
unmountAndReleaseReactRootNode(DOMElement container)
|
||||
```
|
||||
|
||||
Remove a mounted React component from the DOM and clean up its event handlers and state.
|
||||
|
||||
|
||||
#### React.renderComponentToString
|
||||
|
||||
```javascript
|
||||
renderComponentToString(ReactComponent component, function callback)
|
||||
```
|
||||
|
||||
Render a component to its initial HTML. This should only be used on the server. React will call `callback` with an HTML string when the markup is ready. You can use this method to create static site generators, or you can generate HTML on the server and send it down to have a very fast initial page load. If you call `React.renderComponent()` on a node that already has this server-rendered markup, React will preserve it and only attach event handlers, allowing you to have a very performant first-load experience.
|
||||
|
||||
|
||||
### AbstractEvent
|
||||
|
||||
Your event handlers will be passed instances of `AbstractEvent`, a cross-browser wrapper around the browser's native event. It has the same interface as the browser's native event (such as `stopPropagation()` and `preventDefault()`) except they work exactly the same across all browsers.
|
||||
|
||||
If you find that you need the underlying browser event for some reason, simply use the `nativeEvent` attribute to get it.
|
||||
|
||||
|
||||
### ReactComponent
|
||||
|
||||
Component classses created by `createClass()` return instances of `ReactComponent` when called. Most of the time when you're using React you're either creating or consuming `ReactComponent`s.
|
||||
|
||||
|
||||
#### getDOMNode
|
||||
|
||||
```javascript
|
||||
DOMElement getDOMNode()
|
||||
```
|
||||
|
||||
If this component has been mounted into the DOM, this returns the corresponding native browser DOM element. This method is useful for reading values out of the DOM, such as form field values and performing DOM measurements.
|
||||
|
||||
|
||||
#### setProps
|
||||
|
||||
```javascript
|
||||
setProps(object nextProps)
|
||||
```
|
||||
|
||||
When you're integrating with an external JavaScript application you may want to signal a change to a React component rendered with `renderComponent()`. Simply call `setProps()` to change its properties and trigger a re-render.
|
||||
|
||||
> Note:
|
||||
>
|
||||
> This method can only be called on a root-level component. That is, it's only available on the component passed directly to `renderComponent()` and none of its children. If you're inclined to use `setProps()` on a child component, instead take advantage of reactive updates and pass the new prop to the child component when it's created in `render()`.
|
||||
|
||||
|
||||
#### replaceProps
|
||||
|
||||
```javascript
|
||||
replaceProps(object nextProps)
|
||||
```
|
||||
|
||||
Like `setProps()` but deletes any pre-existing props that are not in nextProps.
|
||||
|
||||
|
||||
#### transferPropsTo
|
||||
|
||||
```javascript
|
||||
ReactComponent transferPropsTo(ReactComponent targetComponent)
|
||||
```
|
||||
|
||||
Transfer properties from this component to a target component that have not already been set on the target component. This is usually used to pass down properties to the returned root component. `targetComponent`, now updated with some new props is returned as a convenience.
|
||||
|
||||
|
||||
#### setState
|
||||
|
||||
```javascript
|
||||
setState(object nextState[, function callback])
|
||||
```
|
||||
|
||||
Merges nextState with the current state. This is the primary method you use to trigger UI updates from event handlers and server request callbacks. In addition, you can supply an optional callback function that is executed once `setState` is completed.
|
||||
|
||||
> Note:
|
||||
>
|
||||
> *NEVER* mutate `this.state` directly. As calling `setState()` afterwards may replace the mutation you made. Treat `this.state` as if it were immutable.
|
||||
|
||||
> Note:
|
||||
>
|
||||
> `setState()` does not immediately mutate `this.state` but creates a pending state transition. Accessing `this.state` after calling this method can potentially return the existing value.
|
||||
|
||||
> Note:
|
||||
>
|
||||
> There is no guarantee of synchronous operation of calls to `setState` and calls may be batched for performance gains.
|
||||
|
||||
|
||||
#### replaceState
|
||||
|
||||
```javascript
|
||||
replaceState(object nextState[, function callback])
|
||||
```
|
||||
|
||||
Like `setState()` but deletes any pre-existing state keys that are not in nextState.
|
||||
|
||||
|
||||
#### forceUpdate()
|
||||
|
||||
```javascript
|
||||
forceUpdate([function callback])
|
||||
```
|
||||
|
||||
If your `render()` method reads from something other than `this.props` or `this.state` you'll need to tell React when it needs to re-run `render()`. Use `forceUpdate()` to cause React to automatically re-render. This will cause `render()` to be called on the component and all of its children but React will only update the DOM if the markup changes.
|
||||
|
||||
Normally you should try to avoid all uses of `forceUpdate()` and only read from `this.props` and `this.state` in `render()`. This makes your application much simpler and more efficient.
|
||||
|
||||
> Note:
|
||||
>
|
||||
> There is no guarantee of synchronous operation of calls to `forceUpdate` and calls may be batched for performance gains.
|
||||
|
||||
|
||||
#### Lifecycle methods
|
||||
|
||||
```javascript
|
||||
object getInitialState()
|
||||
componentWillMount()
|
||||
componentDidMount(DOMElement domNode)
|
||||
componentWillReceiveProps(object nextProps)
|
||||
boolean shouldComponentUpdate(object nextProps, object nextState)
|
||||
componentWillUpdate(object nextProps, object nextState)
|
||||
ReactComponent render()
|
||||
componentDidUpdate(object prevProps, object prevState, DOMElement domNode)
|
||||
componentWillUnmount()
|
||||
```
|
||||
|
||||
See the [working with the browser](./working-with-the-browser.html) documentation for more details on these lifecycle methods.
|
||||
|
||||
|
||||
## DOM Differences
|
||||
|
||||
React has implemented a browser-independent events and DOM system for performance and cross-browser compatibility reasons. We took the opportunity to clean up a few rough edges in browser DOM implementations.
|
||||
|
||||
* All events (including submit) bubble correctly per the W3C spec
|
||||
* All event objects conform to the W3C spec
|
||||
* All DOM properties and attributes (including event handlers) should be camelCased to be consistent with standard JavaScript style. We intentionally break with the spec here, since the spec is inconsistent.
|
||||
* The `style` attribute accepts a JavaScript object with camelCased properties rather than a CSS string. This is consistent with the DOM `style` JavaScript property, is more efficient, and prevents XSS security holes.
|
||||
* `onChange` behaves as you would expect it to: whenever a form field is changed this event is fired rather than inconsistently on blur. We intentionally break from existing browser behavior because `onChange` is a misnomer for its behavior and React relies on this event to react to user input in real time.
|
||||
@@ -44,7 +44,7 @@ In the root directory of the starter kit, create a `helloworld.html` with the fo
|
||||
</html>
|
||||
```
|
||||
|
||||
The XML syntax inside of JavaScript is called JSX; check out the [JSX syntax](syntax.html) to learn more about it. In order to translate it to vanilla JavaScript we use `<script type="text/jsx">` and include `JSXTransformer.js` to actually perform the transformation in the browser.
|
||||
The XML syntax inside of JavaScript is called JSX; check out the [JSX syntax](jsx-in-depth.html) to learn more about it. In order to translate it to vanilla JavaScript we use `<script type="text/jsx">` and include `JSXTransformer.js` to actually perform the transformation in the browser.
|
||||
|
||||
### Separate File
|
||||
|
||||
@@ -84,7 +84,7 @@ The file `build/helloworld.js` is autogenerated whenever you make a change.
|
||||
/** @jsx React.DOM */
|
||||
React.renderComponent(
|
||||
React.DOM.h1(null, 'Hello, world!'),
|
||||
document.getElementyById('example')
|
||||
document.getElementById('example')
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
4
docs/docs/index.html
Normal file
@@ -0,0 +1,4 @@
|
||||
---
|
||||
layout: redirect
|
||||
destination: getting-started.html
|
||||
---
|
||||
73
docs/docs/ref-01-top-level-api.md
Normal file
@@ -0,0 +1,73 @@
|
||||
---
|
||||
id: top-level-api
|
||||
title: Top-Level API
|
||||
layout: docs
|
||||
permalink: top-level-api.html
|
||||
next: component-api.html
|
||||
---
|
||||
|
||||
## React
|
||||
|
||||
`React` is the entry point to the React framework. If you're using one of the prebuilt packages it's available as a global; if you're using CommonJS modules you can `require()` it.
|
||||
|
||||
|
||||
### 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.initializeTouchEvents
|
||||
|
||||
```javascript
|
||||
initializeTouchEvents(boolean shouldUseTouch)
|
||||
```
|
||||
|
||||
Configure React's event system to handle touch events on mobile devices.
|
||||
|
||||
|
||||
### React.createClass
|
||||
|
||||
```javascript
|
||||
function createClass(object specification)
|
||||
```
|
||||
|
||||
Creates a component given a specification. A component implements a `render` method which returns **one single** child. That child may have an arbitrarily deep child structure. One thing that makes components different than standard prototypal classes is that you don't need to call new on them. They are convenience wrappers that construct backing instances (via new) for you.
|
||||
|
||||
For more information about the specification object, see [Component Specs and Lifecycle](component-specs.html).
|
||||
|
||||
|
||||
### React.renderComponent
|
||||
|
||||
```javascript
|
||||
ReactComponent renderComponent(
|
||||
ReactComponent component,
|
||||
DOMElement container,
|
||||
[function callback]
|
||||
)
|
||||
```
|
||||
|
||||
Renders a React component into the DOM in the supplied `container`.
|
||||
|
||||
If the React component was previously rendered into `container`, this will perform an update on it and only mutate the DOM as necessary to reflect the latest React component.
|
||||
|
||||
If the optional callback is provided, it will be executed after the component is rendered or updated.
|
||||
|
||||
|
||||
### React.unmountAndReleaseReactRootNode
|
||||
|
||||
```javascript
|
||||
unmountAndReleaseReactRootNode(DOMElement container)
|
||||
```
|
||||
|
||||
Remove a mounted React component from the DOM and clean up its event handlers and state.
|
||||
|
||||
|
||||
### React.renderComponentToString
|
||||
|
||||
```javascript
|
||||
renderComponentToString(ReactComponent component, function callback)
|
||||
```
|
||||
|
||||
Render a component to its initial HTML. This should only be used on the server. React will call `callback` with an HTML string when the markup is ready. You can use this method to can generate HTML on the server and send the markup down on the initial request for faster page loads and to allow search engines to crawl your pages for SEO purposes.
|
||||
|
||||
If you call `React.renderComponent()` on a node that already has this server-rendered markup, React will preserve it and only attach event handlers, allowing you to have a very performant first-load experience.
|
||||
109
docs/docs/ref-02-component-api.md
Normal file
@@ -0,0 +1,109 @@
|
||||
---
|
||||
id: component-api
|
||||
title: Component API
|
||||
layout: docs
|
||||
permalink: component-api.html
|
||||
prev: top-level-api.html
|
||||
next: component-specs.html
|
||||
---
|
||||
|
||||
## ReactComponent
|
||||
|
||||
Component classses created by `createClass()` return instances of `ReactComponent` when called. Most of the time when you're using React you're either creating or consuming these component objects.
|
||||
|
||||
|
||||
### getDOMNode
|
||||
|
||||
```javascript
|
||||
DOMElement getDOMNode()
|
||||
```
|
||||
|
||||
If this component has been mounted into the DOM, this returns the corresponding native browser DOM element. This method is useful for reading values out of the DOM, such as form field values and performing DOM measurements.
|
||||
|
||||
|
||||
### setProps
|
||||
|
||||
```javascript
|
||||
setProps(object nextProps)
|
||||
```
|
||||
|
||||
When you're integrating with an external JavaScript application you may want to signal a change to a React component rendered with `renderComponent()`. Simply call `setProps()` to change its properties and trigger a re-render.
|
||||
|
||||
> Note:
|
||||
>
|
||||
> This method can only be called on a root-level component. That is, it's only available on the component passed directly to `renderComponent()` and none of its children. If you're inclined to use `setProps()` on a child component, instead take advantage of reactive updates and pass the new prop to the child component when it's created in `render()`.
|
||||
|
||||
|
||||
### replaceProps
|
||||
|
||||
```javascript
|
||||
replaceProps(object nextProps)
|
||||
```
|
||||
|
||||
Like `setProps()` but deletes any pre-existing props instead of merging the two objects.
|
||||
|
||||
|
||||
### transferPropsTo
|
||||
|
||||
```javascript
|
||||
ReactComponent transferPropsTo(ReactComponent targetComponent)
|
||||
```
|
||||
|
||||
Transfer properties from this component to a target component that have not already been set on the target component. After the props are updated, `targetComponent` is returned as a convenience. This function is useful when creating simple HTML-like components:
|
||||
|
||||
```javascript
|
||||
var Avatar = React.createClass({
|
||||
render: function() {
|
||||
return this.transferPropsTo(
|
||||
<img src={"/avatars/" + this.props.userId + ".png"} userId={null} />
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// <AvatarImage userId={17} width={200} height={200} />
|
||||
```
|
||||
|
||||
Properties that are specified directly on the target component instance (such as `src` and `userId` in the above example) will not be overwritten by `transferPropsTo`.
|
||||
|
||||
> Note:
|
||||
>
|
||||
> Use `transferPropsTo` with caution; it encourages tight coupling and makes it easy to accidentally introduce implicit dependencies between components. When in doubt, it's safer to explicitly copy the properties that you need onto the child component.
|
||||
|
||||
|
||||
### setState
|
||||
|
||||
```javascript
|
||||
setState(object nextState[, function callback])
|
||||
```
|
||||
|
||||
Merges nextState with the current state. This is the primary method you use to trigger UI updates from event handlers and server request callbacks. In addition, you can supply an optional callback function that is executed once `setState` is completed.
|
||||
|
||||
> Notes:
|
||||
>
|
||||
> *NEVER* mutate `this.state` directly, as calling `setState()` afterwards may replace the mutation you made. Treat `this.state` as if it were immutable.
|
||||
>
|
||||
> `setState()` does not immediately mutate `this.state` but creates a pending state transition. Accessing `this.state` after calling this method can potentially return the existing value.
|
||||
>
|
||||
> There is no guarantee of synchronous operation of calls to `setState` and calls may be batched for performance gains.
|
||||
|
||||
|
||||
### replaceState
|
||||
|
||||
```javascript
|
||||
replaceState(object nextState[, function callback])
|
||||
```
|
||||
|
||||
Like `setState()` but deletes any pre-existing state keys that are not in nextState.
|
||||
|
||||
|
||||
### forceUpdate()
|
||||
|
||||
```javascript
|
||||
forceUpdate([function callback])
|
||||
```
|
||||
|
||||
If your `render()` method reads from something other than `this.props` or `this.state`, you'll need to tell React when it needs to re-run `render()` by calling `forceUpdate()`. You'll also need to call `forceUpdate()` if you mutate `this.state` directly.
|
||||
|
||||
Calling `forceUpdate()` will cause `render()` to be called on the component and its children, but React will still only update the DOM if the markup changes.
|
||||
|
||||
Normally you should try to avoid all uses of `forceUpdate()` and only read from `this.props` and `this.state` in `render()`. This makes your application much simpler and more efficient.
|
||||
176
docs/docs/ref-03-component-specs.md
Normal file
@@ -0,0 +1,176 @@
|
||||
---
|
||||
id: component-specs
|
||||
title: Component Specs and Lifecycle
|
||||
layout: docs
|
||||
permalink: component-specs.html
|
||||
prev: component-api.html
|
||||
next: tags-and-attributes.html
|
||||
---
|
||||
|
||||
## Component Specifications
|
||||
|
||||
When creating a component class by invoking `React.createClass()`, you should provide a specification object that contains a `render` method and can optionally contain other lifecycle methods described here.
|
||||
|
||||
|
||||
### render
|
||||
|
||||
```javascript
|
||||
ReactComponent render()
|
||||
```
|
||||
|
||||
The `render()` method is required.
|
||||
|
||||
When called, it should examine `this.props` and `this.state` and return a single child component. This child component can be either a native DOM component (such as `<div>`) or another composite component that you've defined yourself.
|
||||
|
||||
The `render()` function should be *pure*, meaning that it does not modify component state, it returns the same result each time it's invoked, and it does not read from or write to the DOM or otherwise interact with the browser (e.g., by using `setTimeout`). If you need to interact with the browser, perform your work in `componentDidMount()` or the other lifecycle methods instead. Keeping `render()` pure makes server rendering more practical and makes components easier to think about.
|
||||
|
||||
|
||||
### getInitialState
|
||||
|
||||
```javascript
|
||||
object getInitialState()
|
||||
```
|
||||
|
||||
Invoked once when the component is mounted. The return value will be used as the initial value of `this.state`.
|
||||
|
||||
|
||||
### getDefaultProps
|
||||
|
||||
```javascript
|
||||
object getDefaultProps()
|
||||
```
|
||||
|
||||
Invoked once when the component is mounted. Values in the mapping will be set on `this.props` if that prop is not specified by the parent component (i.e. using an `in` check).
|
||||
|
||||
This method is invoked before `getInitialState` and therefore cannot rely on `this.state` or use `this.setState`.
|
||||
|
||||
|
||||
### propTypes
|
||||
|
||||
```javascript
|
||||
object propTypes
|
||||
```
|
||||
|
||||
The `propTypes` object allows you to validate props being passed to your components. For more information about `propTypes`, see [Reusable Components](reusable-components.html).
|
||||
|
||||
<!-- TODO: Document propTypes here directly. -->
|
||||
|
||||
|
||||
### mixins
|
||||
|
||||
```javascript
|
||||
array mixins
|
||||
```
|
||||
|
||||
The `mixins` array allows you to use mixins to share behavior among multiple components. For more information about mixins, see [Reusable Components](reusable-components.html).
|
||||
|
||||
<!-- TODO: Document mixins here directly. -->
|
||||
|
||||
|
||||
## Lifecycle Methods
|
||||
|
||||
Various methods are executed at specific points in a component's lifecycle.
|
||||
|
||||
|
||||
### Mounting: componentWillMount
|
||||
|
||||
```javascript
|
||||
componentWillMount()
|
||||
```
|
||||
|
||||
Invoked immediately before rendering occurs. If you call `setState` within this method, `render()` will see the updated state and will be executed only once despite the state change.
|
||||
|
||||
|
||||
### Mounting: componentDidMount
|
||||
|
||||
```javascript
|
||||
componentDidMount(DOMElement rootNode)
|
||||
```
|
||||
|
||||
Invoked immediately after rendering occurs. At this point in the lifecycle, the component has a DOM representation which you can access via the `rootNode` argument or by calling `this.getDOMNode()`.
|
||||
|
||||
If you want to integrate with other JavaScript frameworks, set timers using `setTimeout` or `setInterval`, or send AJAX requests, perform those operations in this method.
|
||||
|
||||
|
||||
### Updating: componentWillReceiveProps
|
||||
|
||||
```javascript
|
||||
componentWillReceiveProps(object nextProps)
|
||||
```
|
||||
|
||||
Invoked when a component is receiving new props. This method is not called for the initial render.
|
||||
|
||||
Use this as an opportunity to react to a prop transition before `render()` is called by updating the state using `this.setState()`. The old props can be accessed via `this.props`. Calling `this.setState()` within this function will not trigger an additional render.
|
||||
|
||||
```javascript
|
||||
componentWillReceiveProps: function(nextProps) {
|
||||
this.setState({
|
||||
likesIncreasing: nextProps.likeCount > this.props.likeCount
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
> Note:
|
||||
>
|
||||
> There is no analogous method `componentWillReceiveState`. An incoming prop transition may cause a state change, but the opposite is not true. If you need to perform operations in response to a state change, use `componentWillUpdate`.
|
||||
|
||||
|
||||
### Updating: shouldComponentUpdate
|
||||
|
||||
```javascript
|
||||
boolean shouldComponentUpdate(object nextProps, object nextState)
|
||||
```
|
||||
|
||||
Invoked before rendering when new props or state are being received. This method is not called for the initial render or when `forceUpdate` is used.
|
||||
|
||||
Use this as an opportunity to `return false` when you're certain that the
|
||||
transition to the new props and state will not require a component update.
|
||||
|
||||
```javascript
|
||||
shouldComponentUpdate: function(nextProps, nextState) {
|
||||
return !equal(nextProps, this.props) || !equal(nextState, this.state);
|
||||
}
|
||||
```
|
||||
|
||||
If `shouldComponentUpdate` returns false, then `render()` will be completely skipped until the next state change. (In addition, `componentWillUpdate` and `componentDidUpdate` will not be called.)
|
||||
|
||||
By default, `shouldComponentUpdate` always returns true to prevent subtle bugs when `state` is mutated in place, but if you are careful to always treat `state` as immutable and to read only from `props` and `state` in `render()` then you can override `shouldComponentUpdate` with an implementation that compares the old props and state to their replacements.
|
||||
|
||||
If performance is a bottleneck, especially with dozens or hundreds of components, use `shouldComponentUpdate` to speed up your app.
|
||||
|
||||
|
||||
### Updating: componentWillUpdate
|
||||
|
||||
```javascript
|
||||
componentWillUpdate(object nextProps, object nextState)
|
||||
```
|
||||
|
||||
Invoked immediately before rendering when new props or state are being received. This method is not called for the initial render.
|
||||
|
||||
Use this as an opportunity to perform preparation before an update occurs.
|
||||
|
||||
> Note:
|
||||
>
|
||||
> You *cannot* use `this.setState()` in this method. If you need to update state in response to a prop change, use `componentWillReceiveProps` instead.
|
||||
|
||||
|
||||
### Updating: componentDidUpdate
|
||||
|
||||
```javascript
|
||||
componentDidUpdate(object prevProps, object prevState, DOMElement rootNode)
|
||||
```
|
||||
|
||||
Invoked immediately after updating occurs. This method is not called for the initial render.
|
||||
|
||||
Use this as an opportunity to operate on the DOM when the component has been updated.
|
||||
|
||||
|
||||
### Unmounting: componentWillUnmount
|
||||
|
||||
```javascript
|
||||
componentWillUnmount()
|
||||
```
|
||||
|
||||
Invoked immediately before a component is unmounted from the DOM.
|
||||
|
||||
Perform any necessary cleanup in this method, such as invalidating timers or cleaning up any DOM elements that were created in `componentDidMount`.
|
||||
65
docs/docs/ref-04-tags-and-attributes.md
Normal file
@@ -0,0 +1,65 @@
|
||||
---
|
||||
id: tags-and-attributes
|
||||
title: Tags and Attributes
|
||||
layout: docs
|
||||
permalink: tags-and-attributes.html
|
||||
prev: component-specs.html
|
||||
next: events.html
|
||||
---
|
||||
|
||||
## Supported Tags
|
||||
|
||||
React attempts to support all common elements. If you need an element that isn't listed here, please file an issue.
|
||||
|
||||
The following elements are supported:
|
||||
|
||||
|
||||
### HTML Elements
|
||||
|
||||
```
|
||||
a abbr address area article aside audio b base bdi bdo big blockquote body br
|
||||
button canvas caption cite code col colgroup data datalist dd del details dfn
|
||||
div dl dt em embed fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6
|
||||
head header hr html i iframe img input ins kbd keygen label legend li link
|
||||
main map mark menu menuitem meta meter nav noscript object ol optgroup option
|
||||
output p param pre progress q rp rt ruby s samp script section select small
|
||||
source span strong style sub summary sup table tbody td textarea tfoot th
|
||||
thead time title tr track u ul var video wbr
|
||||
```
|
||||
|
||||
### SVG elements
|
||||
|
||||
```
|
||||
circle g line path polyline rect svg text
|
||||
```
|
||||
|
||||
|
||||
## Supported Attributes
|
||||
|
||||
React supports all `data-*` and `aria-*` attributes as well as every attribute
|
||||
in the following lists. Note that all attributes are camel-cased and the attributes `class` and `for` are `className` and `htmlFor`, respectively, to match the DOM API specification.
|
||||
|
||||
For a list of events, see [Supported Events](events.html).
|
||||
|
||||
### HTML Attributes
|
||||
|
||||
```
|
||||
accessKey accept action ajaxify allowFullScreen allowTransparency alt
|
||||
autoComplete autoFocus autoPlay cellPadding cellSpacing charSet checked
|
||||
className colSpan content contentEditable contextMenu controls data dateTime
|
||||
dir disabled draggable encType form frameBorder height hidden href htmlFor
|
||||
httpEquiv icon id label lang list max maxLength method min multiple name
|
||||
pattern poster preload placeholder radioGroup rel readOnly required role
|
||||
rowSpan scrollLeft scrollTop selected size spellCheck src step style tabIndex
|
||||
target title type value width wmode
|
||||
```
|
||||
|
||||
In addition, the non-standard `autoCapitalize` attribute is supported for Mobile Safari.
|
||||
|
||||
### SVG Attributes
|
||||
|
||||
```
|
||||
cx cy d fill fx fy points r stroke strokeLinecap strokeWidth transform x x1 x2
|
||||
version viewBox y y1 y2 spreadMethod offset stopColor stopOpacity
|
||||
gradientUnits gradientTransform
|
||||
```
|
||||
205
docs/docs/ref-05-events.md
Normal file
@@ -0,0 +1,205 @@
|
||||
---
|
||||
id: events
|
||||
title: Event System
|
||||
layout: docs
|
||||
permalink: events.html
|
||||
prev: tags-and-attributes.html
|
||||
next: dom-differences.html
|
||||
---
|
||||
|
||||
## SyntheticEvent
|
||||
|
||||
Your event handlers will be passed instances of `SyntheticEvent`, a cross-browser wrapper around the browser's native event. It has the same interface as the browser's native event, including `stopPropagation()` and `preventDefault()`, except the events work identically across all browsers.
|
||||
|
||||
If you find that you need the underlying browser event for some reason, simply use the `nativeEvent` attribute to get it. Every `SyntheticEvent` object has the following attributes:
|
||||
|
||||
```javascript
|
||||
boolean bubbles
|
||||
boolean cancelable
|
||||
DOMEventTarget currentTarget
|
||||
boolean defaultPrevented
|
||||
Number eventPhase
|
||||
boolean isTrusted
|
||||
DOMEvent nativeEvent
|
||||
void preventDefault()
|
||||
void stopPropagation()
|
||||
DOMEventTarget target
|
||||
Date timeStamp
|
||||
String type
|
||||
```
|
||||
|
||||
|
||||
## Supported Events
|
||||
|
||||
React normalizes events so that they have consistent properties across
|
||||
different browsers.
|
||||
|
||||
|
||||
### Clipboard Events
|
||||
|
||||
Event names:
|
||||
|
||||
```
|
||||
onCopy onCut onPaste
|
||||
```
|
||||
|
||||
Properties:
|
||||
|
||||
```javascript
|
||||
DOMDataTransfer clipboardData
|
||||
```
|
||||
|
||||
|
||||
### Keyboard Events
|
||||
|
||||
Event names:
|
||||
|
||||
```
|
||||
onKeyDown onKeyPress onKeyUp
|
||||
```
|
||||
|
||||
Properties:
|
||||
|
||||
```javascript
|
||||
boolean altKey
|
||||
String char
|
||||
boolean ctrlKey
|
||||
String key
|
||||
String locale
|
||||
Number location
|
||||
boolean metaKey
|
||||
boolean repeat
|
||||
boolean shiftKey
|
||||
```
|
||||
|
||||
|
||||
### Focus Events
|
||||
|
||||
Event names:
|
||||
|
||||
```
|
||||
onFocus onBlur
|
||||
```
|
||||
|
||||
Properties:
|
||||
|
||||
```javascript
|
||||
DOMEventTarget relatedTarget
|
||||
```
|
||||
|
||||
|
||||
### Form Events
|
||||
|
||||
Event names:
|
||||
|
||||
```
|
||||
onChange onInput onSubmit
|
||||
```
|
||||
|
||||
For more information about the onChange event, see [Forms](forms.html).
|
||||
|
||||
|
||||
### Mouse Events
|
||||
|
||||
Event names:
|
||||
|
||||
```
|
||||
onClick onDoubleClick onDrag onDragEnd onDragEnter onDragExit onDragLeave
|
||||
onDragOver onDragStart onDrop onMouseDown onMouseEnter onMouseLeave
|
||||
onMouseMove onMouseUp
|
||||
```
|
||||
|
||||
Properties:
|
||||
|
||||
```javascript
|
||||
boolean altKey
|
||||
Number button
|
||||
Number buttons
|
||||
Number clientX
|
||||
Number clientY
|
||||
boolean ctrlKey
|
||||
boolean metaKey
|
||||
Number pageX
|
||||
Number pageY
|
||||
DOMEventTarget relatedTarget
|
||||
Number screenX
|
||||
Number screenY
|
||||
boolean shiftKey
|
||||
```
|
||||
|
||||
|
||||
### Mutation Events
|
||||
|
||||
Event names:
|
||||
|
||||
```
|
||||
onDOMCharacterDataModified
|
||||
```
|
||||
|
||||
Properties:
|
||||
|
||||
```javascript
|
||||
Number attrChange
|
||||
String attrName
|
||||
String newValue
|
||||
String prevValue
|
||||
Node relatedNode
|
||||
```
|
||||
|
||||
|
||||
### Touch events
|
||||
|
||||
To enable touch events, call `React.initializeTouchEvents(true)` before
|
||||
rendering any component.
|
||||
|
||||
Event names:
|
||||
|
||||
```
|
||||
onTouchCancel onTouchEnd onTouchMove onTouchStart
|
||||
```
|
||||
|
||||
Properties:
|
||||
|
||||
```javascript
|
||||
boolean altKey
|
||||
DOMTouchList changedTouches
|
||||
boolean ctrlKey
|
||||
boolean metaKey
|
||||
boolean shiftKey
|
||||
DOMTouchList targetTouches
|
||||
DOMTouchList touches
|
||||
```
|
||||
|
||||
|
||||
### UI Events
|
||||
|
||||
Event names:
|
||||
|
||||
```
|
||||
onScroll
|
||||
```
|
||||
|
||||
Properties:
|
||||
|
||||
```javascript
|
||||
Number detail
|
||||
DOMAbstractView view
|
||||
```
|
||||
|
||||
|
||||
### Wheel Events
|
||||
|
||||
Event names:
|
||||
|
||||
```
|
||||
onWheel
|
||||
```
|
||||
|
||||
Properties:
|
||||
|
||||
```javascript
|
||||
Number deltaX
|
||||
Number deltaMode
|
||||
Number deltaY
|
||||
Number deltaZ
|
||||
```
|
||||
14
docs/docs/ref-06-dom-differences.md
Normal file
@@ -0,0 +1,14 @@
|
||||
---
|
||||
id: dom-differences
|
||||
title: DOM Differences
|
||||
layout: docs
|
||||
permalink: dom-differences.html
|
||||
prev: events.html
|
||||
---
|
||||
|
||||
React has implemented a browser-independent events and DOM system for performance and cross-browser compatibility reasons. We took the opportunity to clean up a few rough edges in browser DOM implementations.
|
||||
|
||||
* All DOM properties and attributes (including event handlers) should be camelCased to be consistent with standard JavaScript style. We intentionally break with the spec here since the spec is inconsistent.
|
||||
* The `style` attribute accepts a JavaScript object with camelCased properties rather than a CSS string. This is consistent with the DOM `style` JavaScript property, is more efficient, and prevents XSS security holes.
|
||||
* All event objects conform to the W3C spec, and all events (including submit) bubble correctly per the W3C spec. See [Event System](events.html) for more details.
|
||||
* The `onChange` event behaves as you would expect it to: whenever a form field is changed this event is fired rather than inconsistently on blur. We intentionally break from existing browser behavior because `onChange` is a misnomer for its behavior and React relies on this event to react to user input in real time. See [Forms](forms.html) for more details.
|
||||
4
docs/docs/reference.html
Normal file
@@ -0,0 +1,4 @@
|
||||
---
|
||||
layout: redirect
|
||||
destination: top-level-api.html
|
||||
---
|
||||
@@ -99,7 +99,7 @@ React.renderComponent(
|
||||
);
|
||||
```
|
||||
|
||||
Its use is optional but we've found JSX syntax easier to use than plain JavaScript. Read more on the [JSX Syntax article](syntax.html).
|
||||
Its use is optional but we've found JSX syntax easier to use than plain JavaScript. Read more on the [JSX Syntax article](jsx-in-depth.html).
|
||||
|
||||
#### What's going on
|
||||
|
||||
@@ -107,7 +107,7 @@ We pass some methods in a JavaScript object to `React.createClass()` to create a
|
||||
|
||||
The `<div>` tags are not actual DOM nodes; they are instantiations of React `div` components. You can think of these as markers or pieces of data that React knows how to handle. React is **safe**. We are not generating HTML strings so XSS protection is the default.
|
||||
|
||||
You do not have to return basic HTML. You can return a tree of components that you (or someone else built). This is what makes React **composable**: a key tenet of maintainable frontends.
|
||||
You do not have to return basic HTML. You can return a tree of components that you (or someone else) built. This is what makes React **composable**: a key tenet of maintainable frontends.
|
||||
|
||||
`React.renderComponent()` instantiates the root component, starts the framework, and injects the markup into a raw DOM element, provided as the second argument.
|
||||
|
||||
@@ -203,7 +203,17 @@ By surrounding a JavaScript expression in braces inside JSX (as either an attrib
|
||||
|
||||
Markdown is a simple way to format your text inline. For example, surrounding text with asterisks will make it emphasized.
|
||||
|
||||
First, add the third-party **Showdown** library to your application. This is a JavaScript library which takes Markdown text and converts it to raw HTML. This requires a script tag in your head (which we have already included in the React playground).
|
||||
First, add the third-party **Showdown** library to your application. This is a JavaScript library which takes Markdown text and converts it to raw HTML. This requires a script tag in your head (which we have already included in the React playground):
|
||||
|
||||
```html{6}
|
||||
<!-- template.html -->
|
||||
<head>
|
||||
<title>Hello React</title>
|
||||
<script src="http://fb.me/react-{{site.react_version}}.js"></script>
|
||||
<script src="http://fb.me/JSXTransformer-{{site.react_version}}.js"></script>
|
||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/showdown/0.3.1/showdown.min.js"></script>
|
||||
</head>
|
||||
```
|
||||
|
||||
Next, let's convert the comment text to Markdown and output it:
|
||||
|
||||
@@ -314,7 +324,7 @@ Let's replace the hard-coded data with some dynamic data from the server. We wil
|
||||
// tutorial11.js
|
||||
React.renderComponent(
|
||||
<CommentBox url="comments.json" />,
|
||||
document.getElementById('example')
|
||||
document.getElementById('content')
|
||||
);
|
||||
```
|
||||
|
||||
@@ -438,7 +448,7 @@ All we have done here is move the AJAX call to a separate method and call it whe
|
||||
|
||||
Now it's time to build the form. Our `CommentForm` component should ask the user for their name and comment text and send a request to the server to save the comment.
|
||||
|
||||
```javascript{5-8}
|
||||
```javascript{5-9}
|
||||
// tutorial15.js
|
||||
var CommentForm = React.createClass({
|
||||
render: function() {
|
||||
@@ -489,7 +499,7 @@ var CommentForm = React.createClass({
|
||||
|
||||
React attaches event handlers to components using a camelCase naming convention. We attach an `onSubmit` handler to the form that clears the form fields when the form is submitted with valid input.
|
||||
|
||||
We always return `false` from the event handler to prevent the browser's default action of submitting the form. (If you prefer, you can instead take the event as an argument and call `preventDefault()` on it – read more about [event handling](event-handling.html).)
|
||||
We always return `false` from the event handler to prevent the browser's default action of submitting the form. (If you prefer, you can instead take the event as an argument and call `preventDefault()` on it.)
|
||||
|
||||
##### Refs
|
||||
|
||||
@@ -677,4 +687,4 @@ var CommentBox = React.createClass({
|
||||
|
||||
### Congrats!
|
||||
|
||||
You have just built a comment box in a few simple steps. Learn more about React in the [reference](syntax.html) or start hacking! Good luck!
|
||||
You have just built a comment box in a few simple steps. Learn more about [why to use React](why-react.html), or dive into the [API reference](top-level-api.html) and start hacking! Good luck!
|
||||
|
||||
@@ -29,12 +29,14 @@ The uncompressed, development version of React core with inline documentation.
|
||||
```
|
||||
|
||||
#### <a href="http://fb.me/JSXTransformer-{{site.react_version}}.js">JSX Transform</a>
|
||||
The JSX transformer used to support [XML syntax](/react/docs/syntax.html) in JavaScript.
|
||||
The JSX transformer used to support [XML syntax](/react/docs/jsx-in-depth.html) in JavaScript.
|
||||
|
||||
```html
|
||||
<script src="http://fb.me/JSXTransformer-{{site.react_version}}.js"></script>
|
||||
```
|
||||
|
||||
All scripts are also available via [CDNJS](http://cdnjs.com/#react).
|
||||
|
||||
## Bower
|
||||
|
||||
```sh
|
||||
|
||||
BIN
docs/img/blog/dog-tutorial.png
Normal file
|
After Width: | Height: | Size: 59 KiB |
BIN
docs/img/blog/landoflisp.png
Normal file
|
After Width: | Height: | Size: 156 KiB |
BIN
docs/img/blog/markdown_refactor.png
Normal file
|
After Width: | Height: | Size: 7.2 KiB |
BIN
docs/img/blog/quiztime.png
Normal file
|
After Width: | Height: | Size: 22 KiB |
BIN
docs/img/blog/react-hackathon.jpg
Normal file
|
After Width: | Height: | Size: 51 KiB |
BIN
docs/img/blog/react-page.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
docs/img/blog/turboreact.png
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
docs/img/blog/unite.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
docs/img/blog/wolfenstein_react.png
Normal file
|
After Width: | Height: | Size: 121 KiB |
@@ -6,7 +6,7 @@ id: jsx-compiler
|
||||
<div class="jsxCompiler">
|
||||
<h1>JSX Compiler</h1>
|
||||
<p>
|
||||
This tool demonstrates how <a href="/react/docs/syntax.html">JSX syntax</a>
|
||||
This tool demonstrates how <a href="/react/docs/jsx-in-depth.html">JSX syntax</a>
|
||||
is desguared into native JavaScript.
|
||||
</p>
|
||||
<div id="jsxCompiler"></div>
|
||||
|
||||
@@ -6,9 +6,13 @@ id: support
|
||||
|
||||
**React** is worked on full-time by Facebook's product infrastructure and Instagram's user interface engineering teams. They're often around and available for questions.
|
||||
|
||||
## Stack Overflow
|
||||
|
||||
Many members of the community use Stack Overflow to ask questions. Read through the [existing questions](http://stackoverflow.com/questions/tagged/reactjs) tagged with **reactjs** or [ask your own](http://stackoverflow.com/questions/ask)!
|
||||
|
||||
## Google Groups mailing list
|
||||
|
||||
<a href="http://groups.google.com/group/reactjs" target="_blank">The **reactjs** Google Group</a> is the best place to ask questions and find answers.
|
||||
<a href="http://groups.google.com/group/reactjs" target="_blank">The **reactjs** Google Group</a> is also a good place to ask questions and find answers.
|
||||
|
||||
## IRC
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<pre>
|
||||
python -m SimpleHTTPServer
|
||||
</pre>
|
||||
and going to <a href="http://localhost:8080/">http://localhost:8080/</a>.
|
||||
and going to <a href="http://localhost:8000/">http://localhost:8000/</a>.
|
||||
</p>
|
||||
</div>
|
||||
<h4>Example Details</h4>
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
<pre id="chromeServerCLI" class="codeBox">
|
||||
cd /Path/To/This/File
|
||||
python -m SimpleHTTPServer
|
||||
open -a "Google Chrome" <a href="http://localhost:8080/">http://localhost:8080/</a>. </pre>
|
||||
open -a "Google Chrome" <a href="http://localhost:8000/">http://localhost:8000/</a>. </pre>
|
||||
</li>
|
||||
</ol>
|
||||
<h4 id="chromeErrorFooter" style="color: #733"></h4>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<div id="container">
|
||||
<p>
|
||||
To install React, follow the instructions on
|
||||
<a href="http://www.github.com/facebook/react.js/">GitHub</a>.
|
||||
<a href="http://www.github.com/facebook/react/">GitHub</a>.
|
||||
</p>
|
||||
<p>
|
||||
If you can see this, React is not running. You probably didn't run:
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<div id="container">
|
||||
<p>
|
||||
To install React, follow the instructions on
|
||||
<a href="http://www.github.com/facebook/react.js/">GitHub</a>.
|
||||
<a href="http://www.github.com/facebook/react/">GitHub</a>.
|
||||
</p>
|
||||
<p>
|
||||
If you can see this, React is not working right.
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<div id="container">
|
||||
<p>
|
||||
To install React, follow the instructions on
|
||||
<a href="http://www.github.com/facebook/react.js/">GitHub</a>.
|
||||
<a href="http://www.github.com/facebook/react/">GitHub</a>.
|
||||
</p>
|
||||
<p>
|
||||
If you can see this, React is not working right.
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<div id="container">
|
||||
<p>
|
||||
To install React, follow the instructions on
|
||||
<a href="http://www.github.com/facebook/react.js/">GitHub</a>.
|
||||
<a href="http://www.github.com/facebook/react/">GitHub</a>.
|
||||
</p>
|
||||
<p>
|
||||
If you can see this, React is not working right.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-tools",
|
||||
"version": "0.5.0-alpha",
|
||||
"version": "0.4.2",
|
||||
"keywords": [
|
||||
"react",
|
||||
"jsx",
|
||||
@@ -20,6 +20,7 @@
|
||||
"main.js",
|
||||
"bin/jsx",
|
||||
"build/modules/",
|
||||
"src/",
|
||||
"vendor/fbtransform/",
|
||||
"vendor/constants.js"
|
||||
],
|
||||
|
||||
@@ -58,7 +58,7 @@ mixInto(ReactTextComponent, {
|
||||
mountComponent: function(rootID) {
|
||||
ReactComponent.Mixin.mountComponent.call(this, rootID);
|
||||
return (
|
||||
'<span ' + ReactMount.ATTR_NAME + '="' + rootID + '">' +
|
||||
'<span ' + ReactMount.ATTR_NAME + '="' + escapeTextForBrowser(rootID) + '">' +
|
||||
escapeTextForBrowser(this.props.text) +
|
||||
'</span>'
|
||||
);
|
||||
|
||||
@@ -23,7 +23,7 @@ var SyntheticUIEvent = require('SyntheticUIEvent');
|
||||
|
||||
/**
|
||||
* @interface TouchEvent
|
||||
* @see http://www.w3.org/TR/DOM-Level-3-Events/
|
||||
* @see http://www.w3.org/TR/touch-events/
|
||||
*/
|
||||
var TouchEventInterface = {
|
||||
touches: null,
|
||||
|
||||