Browse Source

update add-ons docs based on feedbacks

- Overview of add-ons for the add-ons page.
- Better title for `ReactLink`.
- Nicer code format for classSet example.
- Better explanation for `classSet`.
main
Cheng Lou 11 years ago
parent
commit
12d16c92d8
  1. 6
      _config.yml
  2. 6
      docs/09-addons.md
  3. 2
      docs/09.1-animation.md
  4. 10
      docs/09.2-form-input-binding-sugar.md
  5. 12
      docs/09.3-class-name-manipulation.md

6
_config.yml

@ -52,12 +52,12 @@ nav_docs_sections:
- id: tooling-integration - id: tooling-integration
title: Tooling Integration title: Tooling Integration
- id: addons - id: addons
title: Add-ons title: Add-Ons
subitems: subitems:
- id: animation - id: animation
title: Animation title: Animation
- id: form-input-binding-sugar - id: two-way-binding-helpers
title: Form Input Binding Sugar title: Two-Way Binding Helpers
- id: class-name-manipulation - id: class-name-manipulation
title: Class Name Manipulation title: Class Name Manipulation
- id: examples - id: examples

6
docs/09-addons.md

@ -7,6 +7,10 @@ prev: tooling-integration.html
next: animation.html next: animation.html
--- ---
`React.addons` is where we park some useful utilities for building React apps. **These should be considered experimental** but will eventually be rolled into core or a blessed utilities library. `React.addons` is where we park some useful utilities for building React apps. **These should be considered experimental** but will eventually be rolled into core or a blessed utilities library:
- `ReactTransitions`, for dealing with animations and transitions that are usually not simple to implement, such as before a component's removal.
- `ReactLink`, to simplify the coordination between user's form input data and and the component's state.
- `classSet`, for manipulating the DOM `class` string a bit more cleanly.
To get the add-ons, use `react-with-addons.js` (and its minified counterpart) rather than the common `react.js`. To get the add-ons, use `react-with-addons.js` (and its minified counterpart) rather than the common `react.js`.

2
docs/09.1-animation.md

@ -4,7 +4,7 @@ title: Animation
layout: docs layout: docs
permalink: animation.html permalink: animation.html
prev: addons.html prev: addons.html
next: form-input-binding-sugar.html next: two-way-binding-helpers.html
--- ---
`ReactTransitions` is an easy way to perform CSS transitions and animations when a React component enters or leaves the DOM. It's inspired by the excellent [ng-animate](http://www.nganimate.org/) library. `ReactTransitions` is an easy way to perform CSS transitions and animations when a React component enters or leaves the DOM. It's inspired by the excellent [ng-animate](http://www.nganimate.org/) library.

10
docs/09.2-form-input-binding-sugar.md

@ -1,14 +1,18 @@
--- ---
id: form-input-binding-sugar id: two-way-binding-helpers
title: Form Input Binding Sugar title: Two-Way Binding Helpers
layout: docs layout: docs
permalink: form-input-binding-sugar.html permalink: two-way-binding-helpers.html
prev: animation.html prev: animation.html
next: class-name-manipulation.html next: class-name-manipulation.html
--- ---
`ReactLink` is an easy way to express two-way binding with React. `ReactLink` is an easy way to express two-way binding with React.
> Note:
>
> If you're new to the framework, note that `ReactLink` is not needed for most applications and should be used cautiously.
In React, data flows one way: from owner to child. This is because data only flows one direction in [the Von Neumann model of computing](http://en.wikipedia.org/wiki/Von_Neumann_architecture). You can think of it as "one-way data binding." In React, data flows one way: from owner to child. This is because data only flows one direction in [the Von Neumann model of computing](http://en.wikipedia.org/wiki/Von_Neumann_architecture). You can think of it as "one-way data binding."
However, there are lots of applications that require you to read some data and flow it back into your program. For example, when developing forms, you'll often want to update some React `state` when you receive user input. Or perhaps you want to perform layout in JavaScript and react to changes in some DOM element size. However, there are lots of applications that require you to read some data and flow it back into your program. For example, when developing forms, you'll often want to update some React `state` when you receive user input. Or perhaps you want to perform layout in JavaScript and react to changes in some DOM element size.

12
docs/09.3-class-name-manipulation.md

@ -3,7 +3,7 @@ id: class-name-manipulation
title: Class Name Manipulation title: Class Name Manipulation
layout: docs layout: docs
permalink: class-name-manipulation.html permalink: class-name-manipulation.html
prev: form-input-binding-sugar.html prev: two-way-binding-helpers.html
next: examples.html next: examples.html
--- ---
@ -30,17 +30,17 @@ This can quickly get tedious, as assigning class name strings can be hard to rea
```javascript ```javascript
render: function() { render: function() {
var classSet = React.addons.classSet; var cx = React.addons.classSet;
var classes = { var classes = cx({
'message': true, 'message': true,
'message-important': this.props.isImportant, 'message-important': this.props.isImportant,
'message-read': this.props.isRead 'message-read': this.props.isRead
} })
// same final string, but much cleaner // same final string, but much cleaner
return <div className={classSet(classes)}>Great, I'll be there.</div> return <div className={classes}>Great, I'll be there.</div>
} }
``` ```
Pass to `classSet()` an object, whose key is the CSS class name you might or might not need, and whose value is a boolean (or anything that converts to it) that indicates whether the key should be present in the final class string. When using `classSet()`, pass an object with keys of the CSS class names you might or might not need. Truthy values will result in the key being a part of the resulting string.
No more hacky string concatenations! No more hacky string concatenations!

Loading…
Cancel
Save