Skip to content

Commit 0a255fe

Browse files
committed
Merge branch 'master' of https://github.com/reactjs/reactjs.org into defer-babel-loading
2 parents 36e1185 + 2883359 commit 0a255fe

File tree

90 files changed

+252
-352
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+252
-352
lines changed

.eslintrc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
{
2+
"extends": [
3+
"fbjs"
4+
],
25
"plugins": [
36
"prettier",
47
"react"
58
],
69
"parser": "babel-eslint",
7-
}
10+
"rules": {
11+
"relay/graphql-naming": 0,
12+
"max-len": 0
13+
},
14+
"env": {
15+
"node": true,
16+
"browser": true
17+
}
18+
}

LICENSE.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This repo contains the source code and documentation powering [reactjs.org](http
1515
### Installation
1616

1717
1. `cd reactjs.org` to go into the project root
18-
1. `yarn` to install the website's NPM dependencies
18+
1. `yarn` to install the website's npm dependencies
1919

2020
### Running locally
2121

content/blog/2017-04-07-react-v15.5.0.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ We're discontinuing active maintenance of React Addons packages. In truth, most
113113
- **react-addons-create-fragment** – React 16 will have first-class support for fragments, at which point this package won't be necessary. We recommend using arrays of keyed elements instead.
114114
- **react-addons-css-transition-group** - Use [react-transition-group/CSSTransitionGroup](https://github.com/reactjs/react-transition-group) instead. Version 1.1.1 provides a drop-in replacement.
115115
- **react-addons-linked-state-mixin** - Explicitly set the `value` and `onChange` handler instead.
116-
- **react-addons-pure-render-mixin** - Use [`React.PureComponent`](/docs/react-api.html#react.purecomponent) instead.
117-
- **react-addons-shallow-compare** - Use [`React.PureComponent`](/docs/react-api.html#react.purecomponent) instead.
116+
- **react-addons-pure-render-mixin** - Use [`React.PureComponent`](/docs/react-api.html#reactpurecomponent) instead.
117+
- **react-addons-shallow-compare** - Use [`React.PureComponent`](/docs/react-api.html#reactpurecomponent) instead.
118118
- **react-addons-transition-group** - Use [react-transition-group/TransitionGroup](https://github.com/reactjs/react-transition-group) instead. Version 1.1.1 provides a drop-in replacement.
119119
- **react-addons-update** - Use [immutability-helper](https://github.com/kolodny/immutability-helper) instead, a drop-in replacement.
120120
- **react-linked-input** - Explicitly set the `value` and `onChange` handler instead.

content/blog/2017-09-08-dom-attributes-in-react-16.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ Below is a detailed list of them.
163163
```
164164

165165
React 15: Converts `NaN`s to strings and passes them through.
166-
React 16: Warns and ignores them.
166+
React 16: Converts `NaN`s to strings and passes them through with a warning.
167167

168168
While testing this release, we have also [created an automatically generated table](https://github.com/facebook/react/blob/master/fixtures/attribute-behavior/AttributeTableSnapshot.md) for all known attributes to track potential regressions.
169169

content/blog/2017-09-26-react-v16.0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ Refer to the previous announcement for [suggestions on how to migrate](/blog/201
151151
React 16 includes a number of small breaking changes. These only affect uncommon use cases and we don't expect them to break most apps.
152152

153153
* React 15 had limited, undocumented support for error boundaries using `unstable_handleError`. This method has been renamed to `componentDidCatch`. You can use a codemod to [automatically migrate to the new API](https://github.com/reactjs/react-codemod#error-boundaries).
154-
* `ReactDOM.render` and `ReactDOM.unstable_renderIntoContainer` now return null if called from inside a lifecycle method. To work around this, you can use [portals](https://github.com/facebook/react/issues/10309#issuecomment-318433235) or [refs](https://github.com/facebook/react/issues/10309#issuecomment-318434635).
154+
* `ReactDOM.render` and `ReactDOM.unstable_renderSubtreeIntoContainer` now return null if called from inside a lifecycle method. To work around this, you can use [portals](https://github.com/facebook/react/issues/10309#issuecomment-318433235) or [refs](https://github.com/facebook/react/issues/10309#issuecomment-318434635).
155155
* `setState`:
156156
* Calling `setState` with null no longer triggers an update. This allows you to decide in an updater function if you want to re-render.
157157
* Calling `setState` directly in render always causes an update. This was not previously the case. Regardless, you should not be calling setState from render.

content/docs/accessibility.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ VoiceOver is an integrated screen reader on Apple devices.
263263
Refer to the following guides on how activate and use VoiceOver:
264264

265265
- [WebAIM - Using VoiceOver to Evaluate Web Accessibility](http://webaim.org/articles/voiceover/)
266-
- [Deque - VoiceOver for OSX Keyboard Shortcuts](https://dequeuniversity.com/screenreaders/voiceover-keyboard-shortcuts)
266+
- [Deque - VoiceOver for OS X Keyboard Shortcuts](https://dequeuniversity.com/screenreaders/voiceover-keyboard-shortcuts)
267267
- [Deque - VoiceOver for iOS Shortcuts](https://dequeuniversity.com/screenreaders/voiceover-ios-shortcuts)
268268

269269
#### JAWS in Internet Explorer

content/docs/addons-pure-render-mixin.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ category: Add-Ons
88

99
> Note:
1010
>
11-
> `PureRenderMixin` is a legacy add-on. Use [`React.PureComponent`](/docs/react-api.html#react.purecomponent) instead.
11+
> `PureRenderMixin` is a legacy add-on. Use [`React.PureComponent`](/docs/react-api.html#reactpurecomponent) instead.
1212
1313
**Importing**
1414

content/docs/addons-shallow-compare.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ category: Reference
88

99
> Note:
1010
>
11-
> `shallowCompare` is a legacy add-on. Use [`React.PureComponent`](/docs/react-api.html#react.purecomponent) instead.
11+
> `shallowCompare` is a legacy add-on. Use [`React.PureComponent`](/docs/react-api.html#reactpurecomponent) instead.
1212
1313
**Importing**
1414

@@ -19,7 +19,7 @@ var shallowCompare = require('react-addons-shallow-compare'); // ES5 with npm
1919

2020
## Overview
2121

22-
Before [`React.PureComponent`](/docs/react-api.html#react.purecomponent) was introduced, `shallowCompare` was commonly used to achieve the same functionality as [`PureRenderMixin`](pure-render-mixin.html) while using ES6 classes with React.
22+
Before [`React.PureComponent`](/docs/react-api.html#reactpurecomponent) was introduced, `shallowCompare` was commonly used to achieve the same functionality as [`PureRenderMixin`](pure-render-mixin.html) while using ES6 classes with React.
2323

2424
If your React component's render function is "pure" (in other words, it renders the same result given the same props and state), you can use this helper function for a performance boost in some cases.
2525

content/docs/addons-test-utils.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ mockComponent(
112112

113113
Pass a mocked component module to this method to augment it with useful methods that allow it to be used as a dummy React component. Instead of rendering as usual, the component will become a simple `<div>` (or other tag if `mockTagName` is provided) containing any provided children.
114114

115+
> Note:
116+
>
117+
> `mockComponent()` is a legacy API. We recommend using [shallow rendering](/docs/test-utils.html#shallow-rendering) or [`jest.mock()`](https://facebook.github.io/jest/docs/en/tutorial-react-native.html#mock-native-modules-using-jestmock) instead.
118+
115119
* * *
116120

117121
### `isElement()`

content/docs/addons.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ The add-ons below are in the development (unminified) version of React only:
2121

2222
The add-ons below are considered legacy and their use is discouraged. They will keep working in observable future, but there is no further development.
2323

24-
- [`PureRenderMixin`](pure-render-mixin.html). Use [`React.PureComponent`](/docs/react-api.html#react.purecomponent) instead.
25-
- [`shallowCompare`](shallow-compare.html), a helper function that performs a shallow comparison for props and state in a component to decide if a component should update.
24+
- [`PureRenderMixin`](pure-render-mixin.html). Use [`React.PureComponent`](/docs/react-api.html#reactpurecomponent) instead.
25+
- [`shallowCompare`](shallow-compare.html), a helper function that performs a shallow comparison for props and state in a component to decide if a component should update. We recommend using [`React.PureComponent`](/docs/react-api.html#reactpurecomponent) instead.
2626
- [`update`](update.html). Use [`kolodny/immutability-helper`](https://github.com/kolodny/immutability-helper) instead.
2727
- [`ReactDOMFactories`](dom-factories.html), pre-configured DOM factories to make React easier to use without JSX.
2828

content/docs/handling-events.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,16 @@ class LoggingButton extends React.Component {
139139
```
140140

141141
The problem with this syntax is that a different callback is created each time the `LoggingButton` renders. In most cases, this is fine. However, if this callback is passed as a prop to lower components, those components might do an extra re-rendering. We generally recommend binding in the constructor or using the class fields syntax, to avoid this sort of performance problem.
142+
143+
## Passing Arguments to Event Handlers
144+
145+
Inside a loop it is common to want to pass an extra parameter to an event handler. For example, if `id` is the row ID, either of the following would work:
146+
147+
```js
148+
<button onClick={(e) => this.deleteRow(id, e)}>Delete Row</button>
149+
<button onClick={this.deleteRow.bind(this, id)}>Delete Row</button>
150+
```
151+
152+
The above two lines are equivalent, and use [arrow functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions) and [`Function.prototype.bind`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_objects/Function/bind) respectively.
153+
154+
In both cases, the `e` argument representing the React event will be passed as a second argument after the ID. With an arrow function, we have to pass it explicitly, but with `bind` any further arguments are automatically forwarded.

content/docs/how-to-contribute.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ In order to accept your pull request, we need you to submit a CLA. You only need
9595

9696
### Contribution Prerequisites
9797

98-
* You have `node` installed at v4.0.0+ and `npm` at v2.0.0+.
98+
* You have `node` installed at v6.0.0+ and `npm` at v3.0.0+.
9999
* You have `gcc` installed or are comfortable installing a compiler if needed. Some of our `npm` dependencies may require a compilation step. On OS X, the Xcode Command Line Tools will cover this. On Ubuntu, `apt-get install build-essential` will install the required packages. Similar commands should work on other Linux distros. Windows will require some additional steps, see the [`node-gyp` installation instructions](https://github.com/nodejs/node-gyp#installation) for details.
100100
* You are familiar with `npm` and know whether or not you need to use `sudo` when installing packages globally.
101101
* You are familiar with `git`.
@@ -118,7 +118,7 @@ First, run `npm run build`. This will produce pre-built bundles in `build` folde
118118

119119
The easiest way to try your changes is to run `npm run build` and then open `fixtures/packaging/babel-standalone/dev.html`. This file already uses `react.js` from the `build` folder so it will pick up your changes.
120120

121-
If you want to try your changes in your existing React project, you may copy `build/umd/react.development.js`, `build/umd/react-dom.development.js`, or any other build products into your app and use them instead of the stable version. If your project uses React from npm, you may delete `react` and `react-dom` in its dependencies and use `npm link` to point them to your local `build` folder:
121+
If you want to try your changes in your existing React project, you may copy `build/dist/react.development.js`, `build/dist/react-dom.development.js`, or any other build products into your app and use them instead of the stable version. If your project uses React from npm, you may delete `react` and `react-dom` in its dependencies and use `npm link` to point them to your local `build` folder:
122122

123123
```sh
124124
cd your_project

content/docs/jsx-in-depth.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,19 @@ You can mix together different types of children, so you can use string literals
308308
</div>
309309
```
310310

311-
A React component can't return multiple React elements, but a single JSX expression can have multiple children, so if you want a component to render multiple things you can wrap it in a `div` like this.
311+
A React component can also return an array of elements:
312+
313+
```js
314+
render() {
315+
// No need to wrap list items in an extra element!
316+
return [
317+
// Don't forget the keys :)
318+
<li key="A">First item</li>,
319+
<li key="B">Second item</li>,
320+
<li key="C">Third item</li>,
321+
];
322+
}
323+
```
312324

313325
### JavaScript Expressions as Children
314326

content/docs/lifting-state-up.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ class TemperatureInput extends React.Component {
166166
167167
render() {
168168
const temperature = this.state.temperature;
169+
// ...
169170
```
170171

171172
However, we want these two inputs to be in sync with each other. When we update the Celsius input, the Fahrenheit input should reflect the converted temperature, and vice versa.
@@ -182,6 +183,7 @@ First, we will replace `this.state.temperature` with `this.props.temperature` in
182183
render() {
183184
// Before: const temperature = this.state.temperature;
184185
const temperature = this.props.temperature;
186+
// ...
185187
```
186188

187189
We know that [props are read-only](/docs/components-and-props.html#props-are-read-only). When the `temperature` was in the local state, the `TemperatureInput` could just call `this.setState()` to change it. However, now that the `temperature` is coming from the parent as a prop, the `TemperatureInput` has no control over it.
@@ -194,6 +196,7 @@ Now, when the `TemperatureInput` wants to update its temperature, it calls `this
194196
handleChange(e) {
195197
// Before: this.setState({temperature: e.target.value});
196198
this.props.onTemperatureChange(e.target.value);
199+
// ...
197200
```
198201

199202
>Note:

content/docs/reconciliation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ As a last resort, you can pass item's index in the array as a key. This can work
142142

143143
## Tradeoffs
144144

145-
It is important to remember that the reconciliation algorithm is an implementation detail. React could rerender the whole app on every action; the end result would be the same. We are regularly refining the heuristics in order to make common use cases faster.
145+
It is important to remember that the reconciliation algorithm is an implementation detail. React could rerender the whole app on every action; the end result would be the same. Just to be clear, rerender in this context means calling `render` for all components, it doesn't mean React will unmount and remount them. It will only apply the differences following the rules stated in the previous sections.
146146

147-
In the current implementation, you can express the fact that a subtree has been moved amongst its siblings, but you cannot tell that it has moved somewhere else. The algorithm will rerender that full subtree.
147+
We are regularly refining the heuristics in order to make common use cases faster. In the current implementation, you can express the fact that a subtree has been moved amongst its siblings, but you cannot tell that it has moved somewhere else. The algorithm will rerender that full subtree.
148148

149149
Because React relies on heuristics, if the assumptions behind them are not met, performance will suffer.
150150

content/docs/reference-dom-elements.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,22 @@ function ComponentWithTransition() {
8888

8989
Style keys are camelCased in order to be consistent with accessing the properties on DOM nodes from JS (e.g. `node.style.backgroundImage`). Vendor prefixes [other than `ms`](http://www.andismith.com/blog/2012/02/modernizr-prefixed/) should begin with a capital letter. This is why `WebkitTransition` has an uppercase "W".
9090

91+
React will automatically append a "px" suffix to certain inline style properties. For example:
92+
93+
```js
94+
// This:
95+
<div style={{ height: 10 }}>
96+
Hello World!
97+
</div>;
98+
99+
// Becomes:
100+
<div style="height: 10px;">
101+
Hello World!
102+
</div>
103+
```
104+
105+
Not all style properties are converted to pixel strings though. Certain ones remain unitless (eg `zoom`, `order`, `flex`). A complete list of unitless properties can be seen [here](https://github.com/facebook/react/blob/4131af3e4bf52f3a003537ec95a1655147c81270/src/renderers/dom/shared/CSSProperty.js#L15-L59).
106+
91107
### suppressContentEditableWarning
92108

93109
Normally, there is a warning when an element with children is also marked as `contentEditable`, because it won't work. This attribute suppresses that warning. Don't use this unless you are building a library like [Draft.js](https://facebook.github.io/draft-js/) that manages `contentEditable` manually.

content/docs/reference-pure-render-mixin.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ permalink: docs/pure-render-mixin.html
88

99
> Note
1010
11-
> The `PureRenderMixin` mixin predates `React.PureComponent`. This reference doc is provided for legacy purposes, and you should consider using [`React.PureComponent`](/docs/react-api.html#react.purecomponent) instead.
11+
> The `PureRenderMixin` mixin predates `React.PureComponent`. This reference doc is provided for legacy purposes, and you should consider using [`React.PureComponent`](/docs/react-api.html#reactpurecomponent) instead.
1212
1313
If your React component's render function renders the same result given the same props and state, you can use this mixin for a performance boost in some cases.
1414

content/docs/reference-react-component.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ Returning `false` does not prevent child components from re-rendering when *thei
204204

205205
Currently, if `shouldComponentUpdate()` returns `false`, then [`componentWillUpdate()`](#componentwillupdate), [`render()`](#render), and [`componentDidUpdate()`](#componentdidupdate) will not be invoked. Note that in the future React may treat `shouldComponentUpdate()` as a hint rather than a strict directive, and returning `false` may still result in a re-rendering of the component.
206206

207-
If you determine a specific component is slow after profiling, you may change it to inherit from [`React.PureComponent`](/docs/react-api.html#react.purecomponent) which implements `shouldComponentUpdate()` with a shallow prop and state comparison. If you are confident you want to write it by hand, you may compare `this.props` with `nextProps` and `this.state` with `nextState` and return `false` to tell React the update can be skipped.
207+
If you determine a specific component is slow after profiling, you may change it to inherit from [`React.PureComponent`](/docs/react-api.html#reactpurecomponent) which implements `shouldComponentUpdate()` with a shallow prop and state comparison. If you are confident you want to write it by hand, you may compare `this.props` with `nextProps` and `this.state` with `nextState` and return `false` to tell React the update can be skipped.
208208

209209
* * *
210210

0 commit comments

Comments
 (0)