mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-26 18:58:17 +00:00
Fix typos
Just s/Javascript/Javascript/g and punctuation changes.
This commit is contained in:
@@ -59,7 +59,7 @@ React.createClass({
|
||||
});
|
||||
```
|
||||
|
||||
We could easily implement `shouldComponentUpdate` as follow:
|
||||
We could easily implement `shouldComponentUpdate` as follows:
|
||||
|
||||
```javascript
|
||||
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).
|
||||
|
||||
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
|
||||
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](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.
|
||||
* *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.
|
||||
|
||||
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
|
||||
var x = { foo: "bar" };
|
||||
|
||||
Reference in New Issue
Block a user