Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: facebook/react
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.14.6
Choose a base ref
...
head repository: facebook/react
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.14.7
Choose a head ref

Commits on Jan 6, 2016

  1. Update website for 0.14.6

    zpao committed Jan 6, 2016
    Copy the full SHA
    d5bf8c5 View commit details
  2. Copy the full SHA
    44e90c0 View commit details

Commits on Jan 8, 2016

  1. Merge pull request #5767 from yhagio/patch-2

    Update 10.4-test-utils.md
    (cherry picked from commit bdcb69f)
    zpao committed Jan 8, 2016
    Copy the full SHA
    80cadc6 View commit details
  2. Merge pull request #5775 from facebook/fix-checkbox-wording

    Fix wording to make it more clear that checkbox (input) supports defaultChecked
    (cherry picked from commit 102cd29)
    jimfb authored and zpao committed Jan 8, 2016
    Copy the full SHA
    5879799 View commit details
  3. Merge pull request #5799 from gmcquistin/patch-1

    [docs] Fix typo in ref-08-reconciliation.md
    (cherry picked from commit 78be6f4)
    jimfb authored and zpao committed Jan 8, 2016
    Copy the full SHA
    cf17f32 View commit details
  4. Merge pull request #5801 from zpao/docs-bigger-embeds

    [docs] Bigger jsfiddle embeds
    (cherry picked from commit 31fc7fd)
    zpao committed Jan 8, 2016
    Copy the full SHA
    d590910 View commit details
  5. Merge pull request #5790 from jimfb/componentWillReceiveProps-blogPost

    Blog post explains to verify prop mutations in componentWillReceiveProps
    (cherry picked from commit a158405)
    jimfb authored and zpao committed Jan 8, 2016
    Copy the full SHA
    4206fd1 View commit details
  6. Merge pull request #5806 from Zhangjd/master

    Update thinking-in-react.zh-CN.md
    (cherry picked from commit 23167f2)
    jimfb authored and zpao committed Jan 8, 2016
    Copy the full SHA
    76aa60d View commit details

Commits on Jan 12, 2016

  1. Merge pull request #5834 from spicyj/no-ie8

    blog post: Discontinuing IE 8 Support in React DOM
    (cherry picked from commit dd93eb7)
    sophiebits committed Jan 12, 2016
    Copy the full SHA
    e45c534 View commit details
  2. Merge pull request #5813 from graue/tips-unneeded-finddomnode

    [docs] remove unnecessary findDOMNode from example
    (cherry picked from commit ea0ac61)
    jimfb authored and zpao committed Jan 12, 2016
    Copy the full SHA
    2f21dc6 View commit details
  3. Merge pull request #5814 from zpao/docs-update-attrs-0.14.6

    [docs] Updated supported attrs
    (cherry picked from commit 67e85df)
    zpao committed Jan 12, 2016
    Copy the full SHA
    381fe0b View commit details
  4. Merge pull request #5686 from vitorbal/master

    Improve documentation for using React with Webpack
    (cherry picked from commit f7850dd)
    zpao committed Jan 12, 2016
    Copy the full SHA
    60afae7 View commit details
  5. Merge pull request #5826 from jacenko/master

    Fixed typo in shouldComponentUpdate.png
    (cherry picked from commit 70097ea)
    jimfb authored and zpao committed Jan 12, 2016
    Copy the full SHA
    ecd2da9 View commit details

Commits on Jan 28, 2016

  1. Merge pull request #5732 from iamchenxin/en-docs

    [docs] deleting some unecessary newline
    (cherry picked from commit 9494ec8)
    zpao committed Jan 28, 2016
    Copy the full SHA
    a808423 View commit details
  2. Merge pull request #5735 from cody/refs

    [docs] Small fixes to "more about refs"
    (cherry picked from commit 1da992a)
    zpao committed Jan 28, 2016
    Copy the full SHA
    7594b97 View commit details
  3. Merge pull request #5849 from david0178418/master

    Added additional detail to "props-in-getInitialState" anti-pattern doc
    (cherry picked from commit f1c1544)
    zpao committed Jan 28, 2016
    Copy the full SHA
    9e380c2 View commit details
  4. Merge pull request #5724 from iamchenxin/docs122315

    Update zh-docs with 4865ddf(v0.14.3+)
    (cherry picked from commit 909cba2)
    zpao committed Jan 28, 2016
    Copy the full SHA
    8c27faa View commit details
  5. Merge pull request #5870 from SimenB/patch-1

    Remove the recommendation to use `isMounted` from beginner docs
    (cherry picked from commit e09dfe1)
    jimfb authored and zpao committed Jan 28, 2016
    Copy the full SHA
    2a1dc07 View commit details
  6. Merge pull request #5872 from SimenB/patch-1

    Fix example from #5870 to avoid double rendering
    (cherry picked from commit c7808ca)
    jimfb authored and zpao committed Jan 28, 2016
    Copy the full SHA
    da3c952 View commit details
  7. Merge pull request #5885 from knpwrs/patch-1

    Clarify stateless function component optimizations.
    (cherry picked from commit 7cee502)
    jimfb authored and zpao committed Jan 28, 2016
    Copy the full SHA
    f5dd3e7 View commit details
  8. Merge pull request #5904 from sercaneraslan/master

    Overflow problem fixed
    (cherry picked from commit 096115c)
    zpao committed Jan 28, 2016
    Copy the full SHA
    9adfb08 View commit details
  9. Merge pull request #5912 from chrisbolin/patch-1

    Small copy changes to TestUtils and Perf summaries
    (cherry picked from commit 6f5e619)
    zpao committed Jan 28, 2016
    Copy the full SHA
    5189deb View commit details
  10. Merge pull request #5928 from scjody/patch-1

    Add a link to the list of supported events
    (cherry picked from commit fc547e8)
    zpao committed Jan 28, 2016
    Copy the full SHA
    4ecc108 View commit details
  11. Bump version for 0.14.7 dev

    graue committed Jan 28, 2016
    Copy the full SHA
    44f1a9a View commit details
  12. Merge pull request #5886 from goatslacker/cant-dangerouslysetinnerhtm…

    …l-for-option
    
    Only add children in ReactDOMOption when there are children
    sophiebits authored and graue committed Jan 28, 2016
    Copy the full SHA
    b797075 View commit details
  13. Merge pull request #5891 from zpao/vendor-semi

    Add semicolon for react-dom source files.
    zpao authored and graue committed Jan 28, 2016
    Copy the full SHA
    79732f0 View commit details
  14. Merge pull request #5387 from MattijsKneppers/master

    updated Basic Example with External JSX instructions
    zpao authored and graue committed Jan 28, 2016
    Copy the full SHA
    decfbdf View commit details
  15. Merge pull request #5840 from koba04/release-event-target-on-destructor

    Release syntheticEvent.target on the destructor
    zpao authored and graue committed Jan 28, 2016
    Copy the full SHA
    3285d83 View commit details
  16. Merge pull request #5561 from graue/setstate-cwm

    shallow render: fix setState in componentWillMount
    (cherry picked from commit 8557cc0)
    graue committed Jan 28, 2016
    Copy the full SHA
    49617c3 View commit details
  17. Copy the full SHA
    2f77642 View commit details
  18. Merge pull request #5917 from zeke/homepage-urls

    Fix homepage URLs in package.json files
    (cherry picked from commit ea79138)
    zpao authored and graue committed Jan 28, 2016
    Copy the full SHA
    8fb9daa View commit details
  19. Merge pull request #5922 from zpao/package-empty-deps

    Add empty dependencies for packages
    (cherry picked from commit ed40119)
    zpao authored and graue committed Jan 28, 2016
    Copy the full SHA
    05acd8e View commit details
  20. Copy the full SHA
    7411245 View commit details
  21. v0.14.7

    graue committed Jan 28, 2016
    Copy the full SHA
    88543ce View commit details
Showing with 1,582 additions and 295 deletions.
  1. +1 −0 .gitignore
  2. +11 −1 CHANGELOG.md
  3. +3 −3 README.md
  4. +4 −4 docs/_config.yml
  5. +60 −0 docs/_posts/2016-01-08-A-implies-B-does-not-imply-B-implies-A.md
  6. +10 −0 docs/_posts/2016-01-12-discontinuing-ie8-support.md
  7. +1 −0 docs/css/react.scss
  8. +1 −1 docs/docs/03-interactivity-and-dynamic-uis.md
  9. +1 −1 docs/docs/05-reusable-components.md
  10. +1 −1 docs/docs/07-forms.md
  11. +4 −41 docs/docs/08-working-with-the-browser.md
  12. +7 −5 docs/docs/08.1-more-about-refs.md
  13. +2 −2 docs/docs/10-addons.md
  14. +32 −0 docs/docs/10.10-shallow-compare.zh-CN.md
  15. +117 −0 docs/docs/10.2-form-input-binding-sugar.zh-CN.md
  16. +11 −0 docs/docs/10.3-class-name-manipulation.zh-CN.md
  17. +2 −1 docs/docs/10.4-test-utils.md
  18. +173 −0 docs/docs/12-context.zh-CN.md
  19. +29 −0 docs/docs/conferences.zh-CN.md
  20. +10 −1 docs/docs/getting-started.md
  21. +27 −17 docs/docs/getting-started.zh-CN.md
  22. +1 −3 docs/docs/ref-01-top-level-api.md
  23. +78 −58 docs/docs/ref-01-top-level-api.zh-CN.md
  24. +15 −15 docs/docs/ref-02-component-api.zh-CN.md
  25. +3 −2 docs/docs/ref-03-component-specs.md
  26. +217 −0 docs/docs/ref-03-component-specs.zh-CN.md
  27. +28 −20 docs/docs/ref-04-tags-and-attributes.md
  28. +90 −0 docs/docs/ref-04-tags-and-attributes.zh-CN.md
  29. +1 −2 docs/docs/ref-05-events.md
  30. +47 −3 docs/docs/ref-05-events.zh-CN.md
  31. +16 −0 docs/docs/ref-06-dom-differences.zh-CN.md
  32. +13 −0 docs/docs/ref-07-special-non-dom-attributes.zh-CN.md
  33. +1 −1 docs/docs/ref-08-reconciliation.md
  34. +193 −0 docs/docs/ref-10-glossary.zh-CN.md
  35. +3 −3 docs/docs/thinking-in-react.it-IT.md
  36. +3 −3 docs/docs/thinking-in-react.ko-KR.md
  37. +3 −3 docs/docs/thinking-in-react.md
  38. +58 −58 docs/docs/thinking-in-react.zh-CN.md
  39. +173 −0 docs/docs/videos.zh-CN.md
  40. BIN docs/downloads/react-0.14.6.zip
  41. BIN docs/img/docs/should-component-update.png
  42. +1 −1 docs/js/react-dom.js
  43. +10 −4 docs/js/react.js
  44. +4 −2 docs/tips/10-props-in-getInitialState-as-anti-pattern.md
  45. +10 −8 docs/tips/12-initial-ajax.md
  46. +1 −1 docs/tips/18-use-react-with-other-libraries.ko-KR.md
  47. +1 −1 docs/tips/18-use-react-with-other-libraries.md
  48. +10 −2 examples/basic-commonjs/index.html
  49. +8 −3 examples/basic-jsx-external/index.html
  50. +8 −0 examples/basic-jsx-precompile/index.html
  51. +1 −1 package.json
  52. +3 −2 packages/react-addons/package.json
  53. +4 −3 packages/react-dom/package.json
  54. +2 −2 packages/react/package.json
  55. +1 −1 src/ReactVersion.js
  56. +1 −1 src/package.json
  57. +6 −3 src/renderers/dom/client/syntheticEvents/SyntheticEvent.js
  58. +9 −0 src/renderers/dom/client/syntheticEvents/__tests__/SyntheticEvent-test.js
  59. +4 −1 src/renderers/dom/client/wrappers/ReactDOMOption.js
  60. +8 −0 src/renderers/dom/client/wrappers/__tests__/ReactDOMOption-test.js
  61. +6 −2 src/test/ReactTestUtils.js
  62. +32 −6 src/test/__tests__/ReactTestUtils-test.js
  63. +1 −1 vendor/react-dom-server.js
  64. +1 −1 vendor/react-dom.js
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -24,3 +24,4 @@ chrome-user-data
*.sublime-workspace
.idea
*.iml
.vscode
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
## 0.14.6 (January 6, 2015)
## 0.14.7 (January 28, 2016)

### React
- Fixed bug with `<option>` tags when using `dangerouslySetInnerHTML`
- Fixed memory leak in synthetic event system

### React TestUtils Add-on
- Fixed bug with calling `setState` in `componentWillMount` when using shallow rendering


## 0.14.6 (January 6, 2016)

### React
- Updated `fbjs` dependency to pick up change affecting handling of undefined document.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -37,12 +37,12 @@ The fastest way to get started is to serve JavaScript from the CDN (also availab

```html
<!-- The core React library -->
<script src="https://fb.me/react-0.14.6.js"></script>
<script src="https://fb.me/react-0.14.7.js"></script>
<!-- The ReactDOM Library -->
<script src="https://fb.me/react-dom-0.14.6.js"></script>
<script src="https://fb.me/react-dom-0.14.7.js"></script>
```

We've also built a [starter kit](https://facebook.github.io/react/downloads/react-0.14.6.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](https://facebook.github.io/react/downloads/react-0.14.7.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:

8 changes: 4 additions & 4 deletions docs/_config.yml
Original file line number Diff line number Diff line change
@@ -2,9 +2,9 @@
name: React
description: A JavaScript library for building user interfaces
url: https://facebook.github.io
baseurl: /react
permalink: /blog/:year/:month/:day/:title.html
paginate_path: /blog/page:num/
baseurl: "/react"
permalink: "/blog/:year/:month/:day/:title.html"
paginate_path: "/blog/page:num/"
relative_permalinks: true
paginate: 5
timezone: America/Los_Angeles
@@ -36,4 +36,4 @@ sass:
sass_dir: _css
gems:
- jekyll-redirect-from
react_version: 0.14.5
react_version: 0.14.6
60 changes: 60 additions & 0 deletions docs/_posts/2016-01-08-A-implies-B-does-not-imply-B-implies-A.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
title: "(A => B) !=> (B => A)"
author: jimfb
---

The documentation for `componentWillReceiveProps` states that `componentWillReceiveProps` will be invoked when the props change as the result of a rerender. Some people assume this means "if `componentWillReceiveProps` is called, then the props must have changed", but that conclusion is logically incorrect.

The guiding principle is one of my favorites from formal logic/mathematics:
> A implies B does not imply B implies A
Example: "If I eat moldy food, then I will get sick" does not imply "if I am sick, then I must have eaten moldy food". There are many other reasons I could be feeling sick. For instance, maybe the flu is circulating around the office. Similarly, there are many reasons that `componentWillReceiveProps` might get called, even if the props didn’t change.

If you don’t believe me, call `ReactDOM.render()` three times with the exact same props, and try to predict the number of times `componentWillReceiveProps` will get called:


```js
class Component extends React.Component {
componentWillReceiveProps(nextProps) {
console.log('componentWillReceiveProps', nextProps.data.bar);
}
render() {
return <div>Bar {this.props.data.bar}!</div>;
}
}

var container = document.getElementById('container');

var mydata = {bar: 'drinks'};
ReactDOM.render(<Component data={mydata} />, container);
ReactDOM.render(<Component data={mydata} />, container);
ReactDOM.render(<Component data={mydata} />, container);
```


In this case, the answer is "2". React calls `componentWillReceiveProps` twice (once for each of the two updates). Both times, the value of "drinks" is printed (ie. the props didn’t change).

To understand why, we need to think about what *could* have happened. The data *could* have changed between the initial render and the two subsequent updates, if the code had performed a mutation like this:

```js
var mydata = {bar: 'drinks'};
ReactDOM.render(<Component data={mydata} />, container);
mydata.bar = 'food'
ReactDOM.render(<Component data={mydata} />, container);
mydata.bar = 'noise'
ReactDOM.render(<Component data={mydata} />, container);
```

React has no way of knowing that the data didn’t change. Therefore, React needs to call `componentWillReceiveProps`, because the component needs to be notified of the new props (even if the new props happen to be the same as the old props).

You might think that React could just use smarter checks for equality, but there are some issues with this idea:

* The old `mydata` and the new `mydata` are actually the same physical object (only the object’s internal value changed). Since the references are triple-equals-equal, doing an equality check doesn’t tell us if the value has changed. The only possible solution would be to have created a deep copy of the data, and then later do a deep comparison - but this can be prohibitively expensive for large data structures (especially ones with cycles).
* The `mydata` object might contain references to functions which have captured variables within closures. There is no way for React to peek into these closures, and thus no way for React to copy them and/or verify equality.
* The `mydata` object might contain references to objects which are re-instantiated during the parent's render (ie. not triple-equals-equal) but are conceptually equal (ie. same keys and same values). A deep-compare (expensive) could detect this, except that functions present a problem again because there is no reliable way to compare two functions to see if they are semantically equivalent.

Given the language constraints, it is sometimes impossible for us to achieve meaningful equality semantics. In such cases, React will call `componentWillReceiveProps` (even though the props might not have changed) so the component has an opportunity to examine the new props and act accordingly.

As a result, your implementation of `componentWillReceiveProps` MUST NOT assume that your props have changed. If you want an operation (such as a network request) to occur only when props have changed, your `componentWillReceiveProps` code needs to check to see if the props actually changed.


10 changes: 10 additions & 0 deletions docs/_posts/2016-01-12-discontinuing-ie8-support.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: "Discontinuing IE 8 Support in React DOM"
author: spicyj
---

Since its 2013 release, React has supported all popular browsers, including Internet Explorer 8 and above. We handle normalizing many quirks present in old browser versions, including event system differences, so that your app code doesn't have to worry about most browser bugs.

Today, Microsoft [discontinued support for older versions of IE](https://www.microsoft.com/en-us/WindowsForBusiness/End-of-IE-support). Starting with React v15, we're discontinuing React DOM's support for IE 8. We've heard that most React DOM apps already don't support old versions of Internet Explorer, so this shouldn't affect many people. This change will help us develop faster and make React DOM even better. (We won't actively remove IE 8–related code quite yet, but we will deprioritize new bugs that are reported. If you need to support IE 8 we recommend you stay on React v0.14.)

React DOM will continue to support IE 9 and above for the foreseeable future.
1 change: 1 addition & 0 deletions docs/css/react.scss
Original file line number Diff line number Diff line change
@@ -409,6 +409,7 @@ h1, h2, h3, h4, h5, h6 {
.playgroundPreview {
padding: 0;
width: 600px;
word-wrap: break-word;

pre {
@include code-typography;
2 changes: 1 addition & 1 deletion docs/docs/03-interactivity-and-dynamic-uis.md
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ ReactDOM.render(

## 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.
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 similarly in all browsers 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.

## Under the Hood: Autobinding and Event Delegation

2 changes: 1 addition & 1 deletion docs/docs/05-reusable-components.md
Original file line number Diff line number Diff line change
@@ -254,4 +254,4 @@ However, you may still specify `.propTypes` and `.defaultProps` by setting them
>
> Because stateless functions don't have a backing instance, you can't attach a ref to a stateless function component. Normally this isn't an issue, since stateless functions do not provide an imperative API. Without an imperative API, there isn't much you could do with an instance anyway. However, if a user wants to find the DOM node of a stateless function component, they must wrap the component in a stateful component (eg. ES6 class component) and attach the ref to the stateful wrapper component.
In an ideal world, most of your components would be stateless functions because these stateless components can follow a faster code path within the React core. This is the recommended pattern, when possible.
In an ideal world, most of your components would be stateless functions because in the future we’ll also be able to make performance optimizations specific to these components by avoiding unnecessary checks and memory allocations. This is the recommended pattern, when possible.
2 changes: 1 addition & 1 deletion docs/docs/07-forms.md
Original file line number Diff line number Diff line change
@@ -95,7 +95,7 @@ If you want to initialize the component with a non-empty value, you can supply a

This example will function much like the **Uncontrolled Components** example above.

Likewise, `<input>` supports `defaultChecked` and `<select>` supports `defaultValue`.
Likewise, `<input type="checkbox">` and `<input type="radio">` support `defaultChecked`, and `<select>` supports `defaultValue`.

> Note:
>
45 changes: 4 additions & 41 deletions docs/docs/08-working-with-the-browser.md
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ React provides powerful abstractions that free you from touching the DOM directl

React is very fast because it never talks to the DOM directly. React maintains a fast in-memory representation of the DOM. `render()` methods actually return a *description* of the DOM, and React can compare this description with the in-memory representation to compute the fastest way to update the browser.

Additionally, React implements a full synthetic event system such that all event objects are guaranteed to conform to the W3C spec despite browser quirks, and everything bubbles consistently and efficiently across browsers. You can even use some HTML5 events in IE8!
Additionally, React implements a full synthetic event system such that all event objects are guaranteed to conform to the W3C spec despite browser quirks, and everything bubbles consistently and efficiently across browsers. You can even use some HTML5 events in older browsers that don't ordinarily support them!

Most of the time you should stay within React's "faked browser" world since it's more performant and easier to reason about. However, sometimes you simply need to access the underlying API, perhaps to work with a third-party library like a jQuery plugin. React provides escape hatches for you to use the underlying DOM API directly.

@@ -53,45 +53,8 @@ _Mounted_ composite components also support the following method:

* `component.forceUpdate()` can be invoked on any mounted component when you know that some deeper aspect of the component's state has changed without using `this.setState()`.

## Browser Support and Polyfills
## Browser Support

At Facebook, we support older browsers, including IE8. We've had polyfills in place for a long time to allow us to write forward-thinking JS. This means we don't have a bunch of hacks scattered throughout our codebase and we can still expect our code to "just work". For example, instead of seeing `+new Date()`, we can just write `Date.now()`. Since the open source React is the same as what we use internally, we've carried over this philosophy of using forward thinking JS.
React supports most popular browsers, including Internet Explorer 9 and above.

In addition to that philosophy, we've also taken the stance that we, as authors of a JS library, should not be shipping polyfills as a part of our library. If every library did this, there's a good chance you'd be sending down the same polyfill multiple times, which could be a sizable chunk of dead code. If your product needs to support older browsers, chances are you're already using something like [es5-shim](https://github.com/es-shims/es5-shim).

### Polyfills Needed to Support Older Browsers

`es5-shim.js` from [kriskowal's es5-shim](https://github.com/es-shims/es5-shim) provides the following that React needs:

* `Array.isArray`
* `Array.prototype.every`
* `Array.prototype.forEach`
* `Array.prototype.indexOf`
* `Array.prototype.map`
* `Date.now`
* `Function.prototype.bind`
* `Object.keys`
* `String.prototype.split`
* `String.prototype.trim`

`es5-sham.js`, also from [kriskowal's es5-shim](https://github.com/es-shims/es5-shim), provides the following that React needs:

* `Object.create`
* `Object.freeze`

The unminified build of React needs the following from [paulmillr's console-polyfill](https://github.com/paulmillr/console-polyfill).

* `console.*`

When using HTML5 elements in IE8 including `<section>`, `<article>`, `<nav>`, `<header>`, and `<footer>`, it's also necessary to include [html5shiv](https://github.com/aFarkas/html5shiv) or a similar script.

### Cross-browser Issues

Although React is pretty good at abstracting browser differences, some browsers are limited or present quirky behaviors that we couldn't find a workaround for.

#### onScroll event on IE8

On IE8 the `onScroll` event doesn't bubble and IE8 doesn't have an API to define handlers to the capturing phase of an event, meaning there is no way for React to listen to these events.
Currently a handler to this event is ignored on IE8.

See the [onScroll doesn't work in IE8](https://github.com/facebook/react/issues/631) GitHub issue for more information.
(We don't support older browsers that don't support ES5 methods, but you may find that your apps do work in older browsers if polyfills such as [es5-shim and es5-sham](https://github.com/es-shims/es5-shim) are included in the page. You're on your own if you choose to take this path.)
12 changes: 7 additions & 5 deletions docs/docs/08.1-more-about-refs.md
Original file line number Diff line number Diff line change
@@ -91,11 +91,13 @@ In order to get a reference to a React component, you can either use `this` to g
var MyComponent = React.createClass({
handleClick: function() {
// Explicitly focus the text input using the raw DOM API.
this.myTextInput.focus();
if (this.myTextInput !== null) {
this.myTextInput.focus();
}
},
render: function() {
// The ref attribute adds a reference to the component to
// this.refs when the component is mounted.
// The ref attribute is a callback that saves a reference to the
// component to this.myTextInput when the component is mounted.
return (
<div>
<input type="text" ref={(ref) => this.myTextInput = ref} />
@@ -131,7 +133,7 @@ Refs are a great way to send a message to a particular child instance in a way t

### Cautions:

- *Never* access refs inside of any component's render method - or while any component's render method is even running anywhere in the call stack.
- *Never* access refs inside of any component's render method or while any component's render method is even running anywhere in the call stack.
- If you want to preserve Google Closure Compiler advanced-mode crushing resilience, make sure to never access as a property what was specified as a string. This means you must access using `this.refs['myRefString']` if your ref was defined as `ref="myRefString"`.
- If you have not programmed several apps with React, your first inclination is usually going to be to try to use refs to "make things happen" in your app. If this is the case, take a moment and think more critically about where `state` should be owned in the component hierarchy. Often, it becomes clear that the proper place to "own" that state is at a higher level in the hierarchy. Placing the state there often eliminates any desire to use `ref`s to "make things happen" – instead, the data flow will usually accomplish your goal.
- If you have not programmed several apps with React, your first inclination is usually going to be to try to use refs to "make things happen" in your app. If this is the case, take a moment and think more critically about where state should be owned in the component hierarchy. Often, it becomes clear that the proper place to "own" that state is at a higher level in the hierarchy. Placing the state there often eliminates any desire to use `ref`s to "make things happen" – instead, the data flow will usually accomplish your goal.
- Refs may not be attached to a [stateless function](/react/docs/reusable-components.html#stateless-functions), because the component does not have a backing instance. You can always wrap a stateless component in a standard composite component and attach a ref to the composite component.
4 changes: 2 additions & 2 deletions docs/docs/10-addons.md
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ The React add-ons are a collection of useful utility modules for building React

The add-ons below are in the development (unminified) version of React only:

- [`TestUtils`](test-utils.html), simple helpers for writing test cases (unminified build only).
- [`Perf`](perf.html), for measuring performance and giving you hint where to optimize.
- [`TestUtils`](test-utils.html), simple helpers for writing test cases.
- [`Perf`](perf.html), a performance profiling tool for finding optimization opportunities.

To get the add-ons, install them individually from npm (e.g., `npm install react-addons-pure-render-mixin`). We don't support using the addons if you're not using npm.
32 changes: 32 additions & 0 deletions docs/docs/10.10-shallow-compare.zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
id: shallow-compare-zh-CN
title: 浅比较
permalink: shallow-compare-zh-CN.html
prev: perf-zh-CN.html
next: advanced-performance-zh-CN.html
---

`shallowCompare` 是一个辅助函数 在以ES6类使用React时,完成和 `PureRenderMixin` 相同的功能。

如果你的React组件的绘制函数是 “干净的” (换句话说,它在给定的 props 和 state 下绘制相同的结果),你可以使用这个辅助函数以在某些情况下提升性能。

例如:

```js
var shallowCompare = require('react-addons-shallow-compare');
export class SampleComponent extends React.Component {
shouldComponentUpdate(nextProps, nextState) {
return shallowCompare(this, nextProps, nextState);
}

render() {
return <div className={this.props.className}>foo</div>;
}
}
```

`shallowCompare` 对当前的 `props``nextProps`对象 执行一个浅的相等检查,同样对于 `state``nextState`对象。
它 通过迭代比较对象的keys 并在 对象的key值不严格相等时返回false 实现此功能.

`shallowCompare` 返回 `true` 如果对 props 或 state的浅比较失败,因此组件应该更新。
`shallowCompare` 返回 `false` 如果对 props 或 state的浅比较都通过了,因此组件不应该更新。
Loading