Skip to content

Commit 14c7494

Browse files
committed
changed wording slightly
2 parents a3445b3 + a66e63b commit 14c7494

20 files changed

+189
-128
lines changed

.eslintrc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
{
22
"extends": [
3-
"eslint:recommended",
4-
"plugin:react/recommended"
3+
"fbjs"
54
],
65
"plugins": [
76
"prettier",
87
"react"
98
],
109
"parser": "babel-eslint",
10+
"rules": {
11+
"relay/graphql-naming": 0,
12+
"max-len": 0
13+
},
1114
"env": {
1215
"node": true,
1316
"browser": true

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/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.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@ 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. We recommend using [`React.PureComponent`](/docs/react-api.html#react.purecomponent) instead.
24+
<<<<<<< HEAD
25+
- [`PureRenderMixin`](pure-render-mixin.html). Use [`React.PureComponent`](/docs/react-api.html#reactpurecomponent) instead.
26+
- [`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.
27+
=======
28+
- [`PureRenderMixin`](pure-render-mixin.html). Use [`React.PureComponent`](/docs/react-api.html#reactpurecomponent) instead.
29+
- [`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.
30+
>>>>>>> a66e63b57527a3310573f49064b13dc64d6a0849
2631
- [`update`](update.html). Use [`kolodny/immutability-helper`](https://github.com/kolodny/immutability-helper) instead.
2732
- [`ReactDOMFactories`](dom-factories.html), pre-configured DOM factories to make React easier to use without JSX.
2833

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/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-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

content/docs/reference-test-renderer.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,23 +158,23 @@ Returns the root "test instance" object that is useful for making assertions abo
158158
testInstance.find(test)
159159
```
160160

161-
Find the first descendant test instance for which `test(testInstance)` returns `true`.
161+
Find a single descendant test instance for which `test(testInstance)` returns `true`. If `test(testInstance)` does not return `true` for exactly one test instance, it will throw an error.
162162

163163
### `testInstance.findByType()`
164164

165165
```javascript
166166
testInstance.findByType(type)
167167
```
168168

169-
Find the first descendant test instance with the provided `type`.
169+
Find a single descendant test instance with the provided `type`. If there is not exactly one test instance with the provided `type`, it will throw an error.
170170

171171
### `testInstance.findByProps()`
172172

173173
```javascript
174174
testInstance.findByProps(props)
175175
```
176176

177-
Find the first descendant test instance with the provided `props`.
177+
Find a single descendant test instance with the provided `props`. If there is not exactly one test instance with the provided `props`, it will throw an error.
178178

179179
### `testInstance.findAll()`
180180

content/tutorial/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,7 @@ Check out the final result here: [Final Result](https://codepen.io/gaearon/pen/g
10901090
10911091
If you have extra time or want to practice your new skills, here are some ideas for improvements you could make, listed in order of increasing difficulty:
10921092
1093-
1. Display the move locations in the format "(1, 3)" instead of "6".
1093+
1. Display the move locations in the format "(1, 3)" in the move list.
10941094
2. Bold the currently selected item in the move list.
10951095
3. Rewrite Board to use two loops to make the squares instead of hardcoding them.
10961096
4. Add a toggle button that lets you sort the moves in either ascending or descending order.

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@
1616
"array-from": "^2.1.1",
1717
"babel-eslint": "^8.0.1",
1818
"eslint": "^4.8.0",
19+
"eslint-config-fbjs": "^2.0.0",
1920
"eslint-config-react": "^1.1.7",
20-
"eslint-plugin-flowtype": "^2.37.0",
21+
"eslint-plugin-babel": "^4.1.2",
22+
"eslint-plugin-flowtype": "^2.39.1",
23+
"eslint-plugin-jsx-a11y": "^6.0.2",
2124
"eslint-plugin-prettier": "^2.3.1",
2225
"eslint-plugin-react": "^7.4.0",
26+
"eslint-plugin-relay": "^0.0.19",
2327
"flow-bin": "^0.56.0",
2428
"gatsby": "^1.9.9",
2529
"gatsby-link": "^1.6.9",

src/components/StickyResponsiveSidebar/StickyResponsiveSidebar.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ class StickyResponsiveSidebar extends Component {
147147
boxShadow: '0 0 20px rgba(0, 0, 0, 0.3)',
148148
[media.lessThan('small')]: smallScreenBottomBarStyles,
149149
}}
150-
onClick={this._openNavMenu}>
150+
onClick={this._openNavMenu}
151+
role="button"
152+
tabIndex={0}>
151153
<Container>
152154
<div
153155
css={{

src/html.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ if (process.env.NODE_ENV === `production`) {
1616
try {
1717
stylesStr = require(`!raw-loader!../public/styles.css`);
1818
} catch (e) {
19-
console.log(e);
19+
console.error(e);
2020
}
2121
}
2222

src/templates/components/MetaTitle/index.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,10 @@
1212
import React from 'react';
1313
import {colors} from 'theme';
1414

15-
const MetaTitle = ({
16-
children,
17-
title,
18-
cssProps = {},
19-
onClick,
20-
onDark = false,
21-
}) => (
15+
const MetaTitle = ({children, title, cssProps = {}, onDark = false}) => (
2216
<div
23-
onClick={onClick}
2417
css={{
2518
color: onDark ? colors.subtleOnDark : colors.subtle,
26-
cursor: onClick ? 'pointer' : null,
2719
fontSize: 14,
2820
fontWeight: 700,
2921
lineHeight: 3,

src/templates/components/Sidebar/Section.js

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
'use strict';
1111

12+
import React from 'react';
1213
import {colors, media} from 'theme';
1314
import isItemActive from 'utils/isItemActive';
1415
import MetaTitle from '../MetaTitle';
@@ -25,32 +26,35 @@ const Section = ({
2526
section,
2627
}) => (
2728
<div>
28-
<MetaTitle
29-
onClick={onSectionTitleClick}
30-
cssProps={{
31-
marginTop: 10,
29+
<button
30+
css={{cursor: 'pointer', backgroundColor: 'transparent', border: 0}}
31+
onClick={onSectionTitleClick}>
32+
<MetaTitle
33+
cssProps={{
34+
marginTop: 10,
3235

33-
[media.greaterThan('small')]: {
34-
color: isActive ? colors.text : colors.subtle,
36+
[media.greaterThan('small')]: {
37+
color: isActive ? colors.text : colors.subtle,
3538

36-
':hover': {
37-
color: colors.text,
39+
':hover': {
40+
color: colors.text,
41+
},
3842
},
39-
},
40-
}}>
41-
{section.title}
42-
<ChevronSvg
43-
cssProps={{
44-
marginLeft: 7,
45-
transform: isActive ? 'rotateX(180deg)' : 'rotateX(0deg)',
46-
transition: 'transform 0.2s ease',
43+
}}>
44+
{section.title}
45+
<ChevronSvg
46+
cssProps={{
47+
marginLeft: 7,
48+
transform: isActive ? 'rotateX(180deg)' : 'rotateX(0deg)',
49+
transition: 'transform 0.2s ease',
4750

48-
[media.lessThan('small')]: {
49-
display: 'none',
50-
},
51-
}}
52-
/>
53-
</MetaTitle>
51+
[media.lessThan('small')]: {
52+
display: 'none',
53+
},
54+
}}
55+
/>
56+
</MetaTitle>
57+
</button>
5458
<ul
5559
css={{
5660
marginBottom: 10,

src/utils/isItemActive.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ const isItemActive = (location, item) => {
2626
}
2727
} else if (item.id.includes('html')) {
2828
return location.pathname.includes(item.id);
29-
} else {
30-
const slugId = location.pathname.split('/').slice(-1)[0];
31-
return slugId === slugify(item.id);
3229
}
30+
const slugId = location.pathname.split('/').slice(-1)[0];
31+
return slugId === slugify(item.id);
3332
};
3433

3534
export default isItemActive;

0 commit comments

Comments
 (0)