Browse Source

Fix typos

Just s/Javascript/Javascript/g and punctuation changes.
main
Joshua Go 10 years ago
parent
commit
f20503e106
  1. 8
      docs/11-advanced-performance.md

8
docs/11-advanced-performance.md

@ -59,7 +59,7 @@ React.createClass({
}); });
``` ```
We could easily implement `shouldComponentUpdate` as follow: We could easily implement `shouldComponentUpdate` as follows:
```javascript ```javascript
shouldComponentUpdate: function(nextProps, nextState) { shouldComponentUpdate: function(nextProps, nextState) {
@ -69,7 +69,7 @@ shouldComponentUpdate: function(nextProps, nextState) {
So far so good, dealing with such simple props/state structures is easy. We could even generalize an implementation based on shallow equality and mix it into components. In fact, React already provides such implementation: [PureRenderMixin](/react/docs/pure-render-mixin.html). So far so good, dealing with such simple props/state structures is easy. We could even generalize an implementation based on shallow equality and mix it into components. In fact, React already provides such implementation: [PureRenderMixin](/react/docs/pure-render-mixin.html).
But what if your components' props or state are mutable data structures?. Say the prop the component receives, instead of being a string like `'bar'`, is a Javascript object that contains a string such as, `{ foo: 'bar' }`: But what if your components' props or state are mutable data structures? Say the prop the component receives, instead of being a string like `'bar'`, is a JavaScript object that contains a string such as, `{ foo: 'bar' }`:
```javascript ```javascript
React.createClass({ React.createClass({
@ -133,13 +133,13 @@ Consequently, since we'll miss the change on the prop and short circuit the re-r
## Immutable-js to the rescue ## Immutable-js to the rescue
[Immutable-js](https://github.com/facebook/immutable-js) is a Javascript collections library written by Lee Byron, which Facebook recently open-sourced. It provides *immutable persistent* collections via *structural sharing*. Lets see what these properties mean: [Immutable-js](https://github.com/facebook/immutable-js) is a JavaScript collections library written by Lee Byron, which Facebook recently open-sourced. It provides *immutable persistent* collections via *structural sharing*. Let's see what these properties mean:
* *Immutable*: once created, a collection cannot be altered at another point in time. * *Immutable*: once created, a collection cannot be altered at another point in time.
* *Persistent*: new collections can be created from a previous collection and a mutation such as set. The original collection is still valid after the new collection is created. * *Persistent*: new collections can be created from a previous collection and a mutation such as set. The original collection is still valid after the new collection is created.
* *Structural Sharing*: new collections are created using as much of the same structure as the original collection as possible, reducing copying to a minimum to achieve space efficiency and acceptable performance. If the new collection is equal to the original, the original is often returned. * *Structural Sharing*: new collections are created using as much of the same structure as the original collection as possible, reducing copying to a minimum to achieve space efficiency and acceptable performance. If the new collection is equal to the original, the original is often returned.
Immutability makes tracking changes cheap; a change will always result in a new object so we only need to check if the reference to the object has changed. For example, in this regular Javascript code: Immutability makes tracking changes cheap; a change will always result in a new object so we only need to check if the reference to the object has changed. For example, in this regular JavaScript code:
```javascript ```javascript
var x = { foo: "bar" }; var x = { foo: "bar" };

Loading…
Cancel
Save