\n\
diff --git a/docs/_js/examples/timer.js b/docs/_js/examples/timer.js
index f0488ec403..68f4f65761 100644
--- a/docs/_js/examples/timer.js
+++ b/docs/_js/examples/timer.js
@@ -7,9 +7,9 @@ var Timer = React.createClass({\n\
getInitialState: function() {\n\
return {secondsElapsed: 0};\n\
},\n\
- tick: React.autoBind(function() {\n\
+ tick: function() {\n\
this.setState({secondsElapsed: this.state.secondsElapsed + 1});\n\
- }),\n\
+ },\n\
componentDidMount: function() {\n\
setInterval(this.tick, 1000);\n\
},\n\
diff --git a/docs/docs/01-why-react.md b/docs/docs/01-why-react.md
new file mode 100644
index 0000000000..0968b72906
--- /dev/null
+++ b/docs/docs/01-why-react.md
@@ -0,0 +1,30 @@
+---
+id: why-react
+title: Why React?
+layout: docs
+permalink: why-react.html
+next: displaying-data.html
+---
+React is a JavaScript library for creating user interfaces by Facebook and Instagram. Many people choose to think of React as the **V** in **[MVC](http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller)**.
+
+We built React to solve one problem: **building large applications with data that changes over time**. To do this, React uses two main ideas.
+
+### Simple
+
+Simply express how your app should look at any given point in time, and React will automatically manage all UI updates when your underlying data changes.
+
+### Declarative
+
+When the data changes, React conceptually hits the "refresh" button, and knows to only update the changed parts.
+
+## Build Composable Components
+
+React is all about building reusable components. In fact, with React the *only* thing you do is build components. Since they're so encapsulated, components make code reuse, testing, and separation of concerns easy.
+
+## Give It Five Minutes
+
+React challenges a lot of conventional wisdom, and at first glance some of the ideas may seem crazy. [Give it five minutes](http://37signals.com/svn/posts/3124-give-it-five-minutes) while reading this guide; those crazy ideas have worked for building thousands of components both inside and outside of Facebook and Instagram.
+
+## Learn More
+
+You can learn more about our motivations behind building React in [this blog post](http://facebook.github.io/react/blog/2013/06/05/why-react.html).
diff --git a/docs/docs/02-displaying-data.md b/docs/docs/02-displaying-data.md
new file mode 100644
index 0000000000..72954a596e
--- /dev/null
+++ b/docs/docs/02-displaying-data.md
@@ -0,0 +1,91 @@
+---
+id: displaying-data
+title: Displaying Data
+layout: docs
+permalink: displaying-data.html
+prev: why-react.html
+next: jsx-in-depth.html
+---
+
+The most basic thing you can do with a UI is display some data. React makes it easy to display data and automatically keeps the interface up-to-date when the data changes.
+
+
+## Getting Started
+
+Let's look at a really simple example. Create a `hello-react.html` file with the following code:
+
+```html
+
+
+
+ Hello React
+
+
+
+
+
+
+
+
+```
+
+For the rest of the documentation, we'll just focus on the JavaScript code and assume it's inserted into a template like the one above. Replace the placeholder comment above with the following JS:
+
+```javascript
+/** @jsx React.DOM */
+
+var HelloWorld = React.createClass({
+ render: function() {
+ return (
+
+ Hello, !
+ It is {this.props.date.toTimeString()}
+
+ );
+ }
+});
+
+setInterval(function() {
+ React.renderComponent(
+ ,
+ document.getElementById('example')
+ );
+}, 500);
+```
+
+
+## Reactive Updates
+
+Open `hello-react.html` in a web browser and type your name into the text field. Notice that React is only changing the time string in the UI — any input you put in the text field remains, even though you haven't written any code to manage this behavior. React figures it out for you and does the right thing.
+
+The way we are able to figure this out is that React does not manipulate the DOM unless it needs to. **It uses a fast, internal mock DOM to perform diffs and computes the most efficient DOM mutation for you.**
+
+The inputs to this component are called `props` — short for "properties". They're passed as attributes in JSX syntax. You should think of these as immutable within the component, that is, **never write to `this.props`**.
+
+
+## Components are Just Like Functions
+
+React components are very simple. You can think of them as simple function that take in `props` and `state` (discussed later) and render HTML. Because they're so simple, it makes them very easy to reason about.
+
+> Note:
+>
+> **One limitation**: React components can only render a single root node. If you want to return multiple nodes they *must* be wrapped in a single root.
+
+
+## JSX Syntax
+
+We strongly believe that components are the right way to separate concerns rather than "templates" and "display logic." We think that markup and the code that generates it are intimately tied together. Additionally, display logic is often very complex and using template languages to express it becomes cumbersome.
+
+We've found that the best solution for this problem is to generate markup directly from the JavaScript code such that you can use all of the expressive power of a real programming language to build UIs. In order to make this easier, we've added a very simple, **optional** HTML-like syntax for the function calls that generate markup called JSX.
+
+**JSX lets you write JavaScript function calls with HTML syntax.** To generate a link in React using pure JavaScript you'd write: `React.DOM.a({href: 'http://facebook.github.io/react/'}, 'Hello React!')`. With JSX this becomes `Hello React!`. We've found this has made building React apps easier and designers tend to prefer the syntax, but everyone has their own workflow, so **JSX is not required to use React.**
+
+JSX is very small; the "hello, world" example above uses every feature of JSX. To learn more about it, see [JSX in depth](./02.1-jsx-in-depth.html). Or see the transform in action in [our live JSX compiler](/react/jsx-compiler.html).
+
+JSX is similar to HTML, but not exactly the same. See [JSX gotchas](./02.2-jsx-gotchas.html) for some key differences.
+
+The easiest way to get started with JSX is to use the in-browser `JSXTransformer`. We strongly recommend that you don't use this in production. You can precompile your code using our command-line [react-tools](http://npmjs.org/package/react-tools) package.
diff --git a/docs/docs/syntax.md b/docs/docs/02.1-jsx-in-depth.md
similarity index 68%
rename from docs/docs/syntax.md
rename to docs/docs/02.1-jsx-in-depth.md
index 570f933826..7be45709b9 100644
--- a/docs/docs/syntax.md
+++ b/docs/docs/02.1-jsx-in-depth.md
@@ -1,18 +1,17 @@
---
-id: docs-syntax
-title: JSX Syntax
-description: Writing JavaScript with XML syntax.
+id: jsx-in-depth
+title: JSX in Depth
layout: docs
-prev: common-questions.html
-next: component-basics.html
+permalink: jsx-in-depth.html
+prev: displaying-data.html
+next: jsx-gotchas.html
---
-JSX is a JavaScript XML syntax transform recommended (but not required) for use
+JSX is a JavaScript XML syntax transform recommended for use
with React.
-## Why JSX?
-First of all, **don't use JSX if you don't like it!**
+## Why JSX?
React works out of the box without JSX. Simply construct your markup using the
functions on `React.DOM`. For example, here's how to construct a simple link:
@@ -23,21 +22,22 @@ var link = React.DOM.a({href: 'http://facebook.github.io/react'}, 'React');
We recommend using JSX for many reasons:
-- It's easier to visualize the structure of the DOM.
-- Designers are more comfortable making changes.
-- It's familiar for those who have used MXML or XAML.
+* It's easier to visualize the structure of the DOM.
+* Designers are more comfortable making changes.
+* It's familiar for those who have used MXML or XAML.
+
## The Transform
-JSX transforms XML-like syntax into native JavaScript. It turns XML elements and
-attributes into function calls and objects, respectively.
+JSX transforms from an XML-like syntax into native JavaScript. XML elements and
+attributes are transformed into function calls and objects, respectively.
```javascript
var Nav;
// Input (JSX):
var app = ;
// Output (JS):
-var app = Nav({color:'blue'}, null);
+var app = Nav({color:"blue"});
```
Notice that in order to use ``, the `Nav` variable must be in scope.
@@ -49,7 +49,7 @@ var Nav, Profile;
// Input (JSX):
var app = ;
// Output (JS):
-var app = Nav({color:'blue'}, Profile(null, 'click'));
+var app = Nav({color:"blue"}, Profile(null, "click"));
```
Use the [JSX Compiler](/react/jsx-compiler.html) to try out JSX and see how it
@@ -63,16 +63,17 @@ how to setup compilation.
> Details about the code transform are given here to increase understanding, but
> your code should not rely on these implementation details.
+
## React and JSX
React and JSX are independent technologies, but JSX was primarily built with
React in mind. The two valid uses of JSX are:
-- To construct instances of React DOM components (`React.DOM.*`).
-- To construct instances of composite components created with
+* To construct instances of React DOM components (`React.DOM.*`).
+* To construct instances of composite components created with
`React.createClass()`.
-**React DOM Components**
+### React DOM Components
To construct a `
` is to create a variable that refers to `React.DOM.div`.
@@ -81,7 +82,7 @@ var div = React.DOM.div;
var app =
Hello, React!
;
```
-**React Component Components**
+### React Component Components
To construct an instance of a composite component, create a variable that
references the class.
@@ -114,7 +115,7 @@ var Nav;
// Input (JSX):
var tree = ;
// Output (JS):
-var tree = Nav(null, React.DOM.span(null, null));
+var tree = Nav(null, React.DOM.span(null));
```
> Remember:
@@ -125,7 +126,7 @@ var tree = Nav(null, React.DOM.span(null, null));
## JavaScript Expressions
-#### Attribute Expressions
+### Attribute Expressions
To use a JavaScript expression as an attribute value, wrap the expression in a
pair of curly braces (`{}`) instead of quotes (`""`).
@@ -137,7 +138,7 @@ var person = ;
var person = Person({name: window.isLoggedIn ? window.name : ''});
```
-#### Child Expressions
+### Child Expressions
Likewise, JavaScript expressions may be used to express children:
@@ -145,16 +146,23 @@ Likewise, JavaScript expressions may be used to express children:
// Input (JSX):
var content = {window.isLoggedIn ? : };
// Output (JS):
-var content = Container(null, window.isLoggedIn ? Nav(null, null) : Login(null, null));
+var content = Container(null, window.isLoggedIn ? Nav(null) : Login(null));
+```
+
+### Comments
+
+It's easy to add comments within your JSX; they're just JS expressions:
+```javascript
+var content = {/* this is a comment */};
```
## Tooling
Beyond the compilation step, JSX does not require any special tools.
-- Many editors already include reasonable support for JSX (Vim, Emacs js2-mode).
-- Linting provides accurate line numbers after compiling without sourcemaps.
-- Elements use standard scoping so linters can find usage of out-of-scope
+* Many editors already include reasonable support for JSX (Vim, Emacs js2-mode).
+* Linting provides accurate line numbers after compiling without sourcemaps.
+* Elements use standard scoping so linters can find usage of out-of-scope
components.
## Prior Work
@@ -163,6 +171,8 @@ JSX is similar to several other JavaScript embedded XML language
proposals/projects. Some of the features of JSX that distinguish it from similar
efforts include:
-- JSX is a simple syntactic transform.
-- JSX neither provides nor requires a runtime library.
-- JSX does not alter or add to the semantics of JavaScript.
+* JSX is a simple syntactic transform.
+* JSX neither provides nor requires a runtime library.
+* JSX does not alter or add to the semantics of JavaScript.
+
+JSX is similar to HTML, but not exactly the same. See [JSX gotchas](./jsx-gotchas.html) for some key differences.
diff --git a/docs/docs/jsx-is-not-html.md b/docs/docs/02.2-jsx-gotchas.md
similarity index 77%
rename from docs/docs/jsx-is-not-html.md
rename to docs/docs/02.2-jsx-gotchas.md
index 42013e9196..0b89ad18db 100644
--- a/docs/docs/jsx-is-not-html.md
+++ b/docs/docs/02.2-jsx-gotchas.md
@@ -1,14 +1,16 @@
---
-id: docs-jsx-is-not-html
-title: JSX is not HTML
-description: Differences between JSX and HTML.
+id: jsx-gotchas
+title: JSX Gotchas
layout: docs
-prev: api.html
+permalink: jsx-gotchas.html
+prev: jsx-in-depth.html
+next: interactivity-and-dynamic-uis.html
---
JSX looks like HTML but there are some important differences you may run into.
-## Whitespace removal
+
+## Whitespace Removal
JSX doesn't follow the same whitespace elimination rules as HTML. JSX removes all whitespace between two curly braces expressions. If you want to have whitespace, simply add `{' '}`.
@@ -18,6 +20,7 @@ JSX doesn't follow the same whitespace elimination rules as HTML. JSX removes al
Follow [Issue #65](https://github.com/facebook/react/issues/65) for discussion on this behavior.
+
## HTML Entities
You can insert HTML entities within literal text in JSX:
@@ -58,27 +61,6 @@ As a last resort, you always have the ability to insert raw HTML.
```
-## Comments
-
-JSX supports both single-line and multi-line JavaScript comments within a tag declaration:
-
-```javascript
-
-```
-
-As of React 0.3, there is no good way to insert comments within the children section. [Issue #82](https://github.com/facebook/react/issues/82) is tracking progress to enable the following:
-
-```javascript
-// Note: This is not implemented yet!
-
- {/* This is a comment */}
-
-```
## Custom HTML Attributes
diff --git a/docs/docs/03-interactivity-and-dynamic-uis.md b/docs/docs/03-interactivity-and-dynamic-uis.md
new file mode 100644
index 0000000000..f679bf9843
--- /dev/null
+++ b/docs/docs/03-interactivity-and-dynamic-uis.md
@@ -0,0 +1,89 @@
+---
+id: interactivity-and-dynamic-uis
+title: Interactivity and Dynamic UIs
+layout: docs
+permalink: interactivity-and-dynamic-uis.html
+prev: jsx-gotchas.html
+next: multiple-components.html
+---
+
+You've already [learned how to display data](./displaying-data.html) with React. Now let's look at how to make our UIs interactive.
+
+
+## A Simple Example
+
+```javascript
+/** @jsx React.DOM */
+
+var LikeButton = React.createClass({
+ getInitialState: function() {
+ return {liked: false};
+ },
+ handleClick: function(event) {
+ this.setState({liked: !this.state.liked});
+ },
+ render: function() {
+ var text = this.state.liked ? 'like' : 'unlike';
+ return (
+
+ You {text} this. Click to toggle.
+
+ );
+ }
+});
+
+React.renderComponent(
+ ,
+ document.getElementById('example')
+);
+```
+
+
+## Event Handling and Synthetic Events
+
+With React you simply pass your event handler as a camelCased prop similar to how you'd do it in normal HTML. React ensures that all events behave identically in IE8 and above by implementing a synthetic event system. That is, React knows how to bubble and capture events according to the spec, and the events passed to your event handler are guaranteed to be consistent with [the W3C spec](http://www.w3.org/TR/DOM-Level-3-Events/), regardless of which browser you're using.
+
+If you'd like to use React on a touch device (i.e. a phone or tablet), simply call `React.initializeTouchEvents(true);` to turn them on.
+
+
+## Under the Hood: autoBind and Event Delegation
+
+Under the hood React does a few things to keep your code performant and easy to understand.
+
+**Autobinding:** When creating callbacks in JavaScript you usually need to explicitly bind a method to its instance such that the value of `this` is correct. With React, every method is automatically bound to its component instance. React caches the bound method such that it's extremely CPU and memory efficient. It's also less typing!
+
+**Event delegation:** React doesn't actually attach event handlers to the nodes themselves. When React starts up, it starts listening for all events at the top level using a single event listener. When a component is mounted or unmounted, the event handlers are simply added or removed from an internal mapping. When an event occurs, React knows how to dispatch it using this mapping. When there are no event handlers left in the mapping, React's event handlers are simple no-ops. To learn more about why this is fast, see [David Walsh's excellent blog post](http://davidwalsh.name/event-delegate).
+
+
+## Components are Just State Machines
+
+React thinks of UIs as simple state machines. By thinking of a UI as being in various states and rendering those states, it's easy to keep your UI consistent.
+
+In React, you simply update a component's state, and then render a new UI based on this new state. React takes care of updating the DOM for you in the most efficient way.
+
+
+## How State Works
+
+A common way to inform React of a data change is by calling `setState(data, callback)`. This method merges `data` into `this.state` and re-renders the component. When the component finishes re-rendering, the optional `callback` is called. Most of the time you'll never need to provide a `callback` since React will take care of keeping your UI up-to-date for you.
+
+
+## What Components Should Have State?
+
+Most of your components should simply take some data from `props` and render it. However, sometimes you need to respond to user input, a server request or the passage of time. For this you use state.
+
+**Try to keep as many of your components as possible stateless.** By doing this you'll isolate the state to its most logical place and minimize redundancy, making it easier to reason about your application.
+
+A common pattern is to create several stateless components that just render data, and have a stateful component above them in the hierarchy that passes its state to its children via `props`. The stateful component encapsulates all of the interaction logic, while the stateless components take care of rendering data in a declarative way.
+
+
+## What *Should* Go in State?
+
+**State should contain data that a component's event handlers may change to trigger a UI update.** In real apps this data tends to be very small and JSON-serializable. When building a stateful component, think about the minimal possible representation of its state, and only store those properties in `this.state`. Inside of `render()` simply compute any other information you need based on this state. You'll find that thinking about and writing applications in this way tends to lead to the most correct application, since adding redundant or computed values to state means that you need to explicitly keep them in sync rather than rely on React computing them for you.
+
+## What *Shouldn't* Go in State?
+
+`this.state` should only contain the minimal amount of data needed to represent your UI's state. As such, it should not contain:
+
+* **Computed data:** Don't worry about precomputing values based on state — it's easier to ensure that your UI is consistent if you do all computation within `render()`. For example, if you have an array of list items in state and you want to render the count as a string, simply render `this.state.listItems.length + ' list items'` in your `render()` method rather than storing it on state.
+* **React components:** Build them in `render()` based on underlying props and state.
+* **Duplicated data from propsL** Try to use props as the source of truth where possible. Because props can change over time, it's appropriate to store props in state to be able to know its previous values.
diff --git a/docs/docs/04-multiple-components.md b/docs/docs/04-multiple-components.md
new file mode 100644
index 0000000000..82e8b73ec1
--- /dev/null
+++ b/docs/docs/04-multiple-components.md
@@ -0,0 +1,151 @@
+---
+id: multiple-components
+title: Multiple Components
+layout: docs
+permalink: multiple-components.html
+prev: interactivity-and-dynamic-uis.html
+next: reusable-components.html
+---
+
+So far, we've looked at how to write a single component to display data and handle user input. Next let's examine one of React's finest features: composability.
+
+
+## Motivation: Separation of Concerns
+
+By building modular components that reuse other components with well-defined interfaces, you get much of the same benefits that you get by using functions or classes. Specifically you can *separate the different concerns* of your app however you please simply by building new components. By building a custom component library for your application, you are expressing your UI in a way that best fits your domain.
+
+
+## Composition Example
+
+Let's create a simple Avatar component which shows a profile picture and username using the Facebook Graph API.
+
+```javascript
+/** @jsx React.DOM */
+
+var Avatar = React.createClass({
+ render: function() {
+ return (
+
+
+
+
+ );
+ }
+});
+
+var ProfilePic = React.createClass({
+ render: function() {
+ return (
+
+ );
+ }
+});
+
+var ProfileLink = React.createClass({
+ render: function() {
+ return (
+
+ {this.props.username}
+
+ );
+ }
+});
+
+React.renderComponent(
+ ,
+ document.getElementById('example')
+);
+```
+
+
+## Ownership
+
+In the above example, instances of `Avatar` *own* instances of `ProfilePic` and `ProfileLink`. In React, **an owner is the component that sets the `props` of other components**. More formally, if a component `X` is created in component `Y`'s `render()` method, it is said that `X` is *owned by* `Y`. As discussed earlier, a component cannot mutate its `props` — they are always consistent with what its owner sets them to. This key property leads to UIs that are guaranteed to be consistent.
+
+It's important to draw a distinciton between the owner-ownee relationship and the parent-child relationship. The owner-ownee relationship is specific to React, while the parent-child relationship is simply the one you know and love from the DOM. In the example above, `Avatar` owns the `div`, `ProfilePic` and `ProfileLink` instances, and `div` is the **parent** (but not owner) of the `ProfilePic` and `ProfileLink` instances.
+
+
+## Children
+
+When you create a React component instance, you can include additional React components or JavaScript expressions between the opening and closing tags like this:
+
+```javascript
+
+```
+
+`Parent` can read its children by accessing the special `this.props.children` prop.
+
+
+### Child Reconciliation
+
+**Reconciliation is the process by which React updates the DOM with each new render pass.** In general, children are reconciled according to the order in which they are rendered. For example, suppose two render passes generate the following respective markup:
+
+```html
+// Render Pass 1
+
+
Paragraph 1
+
Paragraph 2
+
+// Render Pass 2
+
+
Paragraph 2
+
+```
+
+Intuitively, `
Paragraph 1
` was removed. Instead, React will reconcile the DOM by changing the text content of the first child and destroying the last child. React reconciles according to the *order* of the children.
+
+
+### Stateful Children
+
+For most components, this is not a big deal. However, for stateful components that maintain data in `this.state` across render passes, this can be very problematic.
+
+In most cases, this can be sidestepped by hiding elements instead of destroying them:
+
+```html
+// Render Pass 1
+
+
Paragraph 1
+
Paragraph 2
+
+// Render Pass 2
+
+
Paragraph 1
+
Paragraph 2
+
+```
+
+
+### Dynamic Children
+
+The situation gets more complicated when the children are shuffled around (as in search results) or if new components are added onto the front of the list (as in streams). In these cases where the identity and state of each child must be maintained across render passes, you can uniquely identify each child by assigning it a `key`:
+
+```javascript
+ render: function() {
+ var results = this.props.results;
+ return (
+
+ {this.results.map(function(result) {
+ return
{result.text}
;
+ })}
+
+ );
+ }
+```
+
+When React reconciles the keyed children, it will ensure that any child with `key` will be reordered (instead of clobbered) or destroyed (instead of reused).
+
+
+## Data Flow
+
+In React, data flows from owner to owned component through `props` as discussed above. This is effectively one-way data binding: owners bind their owned component's props to some value the owner has computed based on its `props` or `state`. Since this process happens recursively, data changes are automatically reflected everywhere they are used.
+
+
+## A Note on Performance
+
+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.
+
+> Note:
+>
+> If `shouldComponentUpdate()` returns false when data has actually changed, React can't keep your UI in sync. Be sure you know what you're doing while using it, and only use this function when you have a noticeable performance problem. Don't underestimate how fast JavaScript is relative to the DOM.
diff --git a/docs/docs/05-reusable-components.md b/docs/docs/05-reusable-components.md
new file mode 100644
index 0000000000..3b2f979220
--- /dev/null
+++ b/docs/docs/05-reusable-components.md
@@ -0,0 +1,96 @@
+---
+id: reusable-components
+title: Reusable Components
+layout: docs
+permalink: reusable-components.html
+prev: multiple-components.html
+next: forms.html
+---
+
+When designing interfaces, break down the common design elements (buttons, form fields, layout components, etc) into reusable components with well-defined interfaces. That way, the next time you need to build some UI you can write much less code, which means faster development time, less bugs, and less bytes down the wire.
+
+
+## Prop Validation
+
+As your app grows it's helpful to ensure that your components are used correctly. We do this using `propTypes`.
+
+** TODO zpao **
+
+
+## Transferring Props: A Shortcut
+
+A common type of React component is one that extends a basic HTML in a simple way. Often you'll want to copy any HTML attributes passed to your component to the underlying HTML element to save typing. React provides `transferPropsTo()` to do just this.
+
+```javascript
+/** @jsx React.DOM */
+
+var CheckLink = React.createClass({
+ render: function() {
+ // transferPropsTo() will take any props pased to CheckLink
+ // and copy them to
+ return this.transferPropsTo({'√ '}{this.props.children});
+ }
+});
+
+React.renderComponent(
+
+ Click here!
+ ,
+ document.getElementById('example')
+);
+```
+
+
+## Mixins
+
+Components are the best way to reuse code in React, but sometimes very different components may share some common functionality. These are sometimes called [cross-cutting concerns](http://en.wikipedia.org/wiki/Cross-cutting_concern). React provides `mixins` to solve this problem.
+
+One common use case is a component wanting to update itself on a time interval. It's easy to use `setInterval()`, but it's important to cancel your interval when you don't need it anymore to save memory. React provides [lifecycle methods](./working-with-the-browser.html) that let you know when a component is about to be created or destroyed. Let's create a simple mixin that uses these methods to provide an easy `setInterval()` function that will automatically get cleaned up when your component is destroyed.
+
+```javascript
+/** @jsx React.DOM */
+
+var SetIntervalMixin = {
+ componentWillMount: function() {
+ this.intervals = [];
+ },
+ setInterval: function() {
+ this.intervals.push(setInterval.apply(null, arguments));
+ },
+ componentWillUnmount: function() {
+ this.intervals.map(clearInterval);
+ }
+};
+
+var TickTock = React.createClass({
+ mixins: [SetIntervalMixin], // Use the mixin
+ getInitialState: function() {
+ return {seconds: 0};
+ },
+ componentDidMount: function() {
+ this.setInterval(this.tick, 1000); // Call a method on the mixin
+ },
+ tick: function() {
+ this.setState({seconds: this.state.seconds + 1});
+ },
+ render: function() {
+ return (
+
+ React has been running for {this.state.seconds} seconds.
+
+ );
+ }
+});
+
+React.renderComponent(
+ ,
+ document.getElementById('example')
+);
+```
+
+A nice feature of mixins is that if a component is using multiple mixins and several mixins define the same lifecycle method (i.e. several mixins want to do some cleanup when the component is destroyed), all of the lifecycle methods are guaranteed to be called.
+
+
+## Testing
+
+**TODO: benjamn**
diff --git a/docs/docs/06-forms.md b/docs/docs/06-forms.md
new file mode 100644
index 0000000000..b2f2323e8f
--- /dev/null
+++ b/docs/docs/06-forms.md
@@ -0,0 +1,132 @@
+---
+id: forms
+title: Forms
+layout: docs
+permalink: forms.html
+prev: reusable-components.html
+next: working-with-the-browser.html
+---
+
+Form components such as ``, `