Skip to content

Commit c65fb8c

Browse files
authored
Merge pull request #1 from reactjs/master
update
2 parents be1f9a6 + 9511271 commit c65fb8c

File tree

300 files changed

+12102
-4326
lines changed

Some content is hidden

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

300 files changed

+12102
-4326
lines changed

Diff for: .circleci/config.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
version: 2
2+
jobs:
3+
build:
4+
docker:
5+
- image: circleci/node:latest
6+
steps:
7+
- checkout
8+
- restore_cache:
9+
keys:
10+
- dependencies-{{ checksum "package.json" }}
11+
# fallback to using the latest cache if no exact match is found
12+
- dependencies-
13+
- run:
14+
name: Install
15+
command: yarn install
16+
- save_cache:
17+
paths:
18+
- node_modules
19+
key: dependencies-{{ checksum "package.json" }}
20+
- run:
21+
name: Check Prettier, ESLint, Flow
22+
command: yarn ci-check

Diff for: .eslintignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ node_modules/*
44
content/*
55

66
# Ignore built files
7-
public/*
7+
public/*
8+
9+
# Ignore examples
10+
examples/*

Diff for: .eslintrc

+12-1
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+
}

Diff for: .github/PULL_REQUEST_TEMPLATE.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
3+
<!--
4+
5+
Thank you for the PR! Contributors like you keep React awesome!
6+
7+
Please see the Contribution Guide for guidelines:
8+
9+
https://github.com/reactjs/reactjs.org/blob/master/CONTRIBUTING.md
10+
11+
If your PR references an existing issue, please add the issue number below
12+
13+
-->

Diff for: .gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.cache
22
.DS_STORE
3+
.idea
34
node_modules
4-
public
5+
public

Diff for: .prettierrc.examples

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"bracketSpacing": false,
3+
"jsxBracketSameLine": true,
4+
"parser": "flow",
5+
"printWidth": 60,
6+
"singleQuote": true,
7+
"trailingComma": "es5"
8+
}

Diff for: CONTRIBUTING.md

+139
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# Contributing
2+
3+
Thank you for your interest in contributing to the React Docs!
4+
5+
## Code of Conduct
6+
7+
Facebook has adopted a Code of Conduct that we expect project
8+
participants to adhere to. Please [read the full text](https://code.facebook.com/codeofconduct)
9+
so that you can understand what actions will and will not be tolerated.
10+
11+
## Guidelines for Text
12+
13+
**Different sections intentionally have different styles.**
14+
15+
The documentation is divided into sections to cater to different learning styles and use cases. When editing an article, try to match the surrounding text in tone and style. When creating a new article, try to match the tone of the other articles in the same section. Learn about the motivation behind each section below.
16+
17+
**[Tutorial](https://reactjs.org/tutorial/tutorial.html)** is relatively informal, and is designed for people who prefer a hands-on approach to learning, and can tolerate skipping theory in favor of practice. Its goal is to give the reader a feel for a typical React workflow rather than to explain fundamentals in detail. Here we focus on *what* to do and spend less time on *how* or *why* we did it. It is extremely important to do a lot of hand-holding and unambiguously describe every single change. It should be possible for a beginner to mechanically follow every instruction, and still get to a working tic-tac-toe game.
18+
19+
**[Quick Start](https://reactjs.org/docs/hello-world.html)** is designed to introduce fundamental concepts in a step-by-step way. Each individual article in Quick Start builds on the knowledge from the previous ones, so make sure not to add any "cyclical dependencies" between them. It is important that the reader can start with the first article and work their way to the last Quick Start article without ever having to "look ahead" for a definition. This explains some ordering choices (e.g. that state is explained before events, or that "thinking in React" doesn't use refs). Quick Start also serves as a reference manual for React concepts, so it is important to be very strict about their definitions and relationships between them. This is, for example, why we introduce elements before components. Resist adding too much detail to Quick Start articles. They intentionally don't cover all corner cases, and focus on establishing firm foundations.
20+
21+
**[Advanced Guides](https://reactjs.org/docs/jsx-in-depth.html)** are deep dives into topics that aren't essential for a beginner developer but that everyone bumps into sooner or later. They don't have a specific order, and target more experienced developers. If you have a set of recipes fitting a particular use case, and those recipes aren't opinionated (most React users would agree on them), this is the place to add them.
22+
23+
**[Reference](https://reactjs.org/docs/react-api.html)** is organized by APIs rather than concepts. It is intended to be exhaustive. Any corner cases or recommendations that were skipped for brevity in Quick Start or Advanced Guides should be mentioned in the reference documentation for the corresponding APIs.
24+
25+
**[Contributing](https://reactjs.org/docs/how-to-contribute.html)** should stay up-to-date and be friendly to relatively experienced developers.
26+
27+
**[FAQ](https://reactjs.org/docs/faq-ajax.html)** has a more conversational tone than the other sections. Here, it's fine to include some content that's not primarily concerned with React, as long as React users are overwhelmingly interested in it (e.g. recommendations on directory structure). It's also okay to show more than a single way to do something in the FAQ, and briefly discuss the tradeoffs. The FAQ prioritizes unblocking people with a working solution over explaining concepts in detail, and can be more opinionated than the rest of the docs, even providing popular library recommendations.
28+
29+
**Try to follow your own instructions.**
30+
31+
When writing step-by-step instructions (e.g. how to install something), try to forget everything you know about the topic, and actually follow the instructions you wrote, a single step at time. Often you will discover that there is implicit knowledge that you forgot to mention, or that there are missing or out-of-order steps in the instructions. Bonus points for getting *somebody else* to follow the steps and watching what they struggle with. Often it would be something very simple that you have not anticipated.
32+
33+
## Guidelines for Code Examples
34+
35+
### Syntax
36+
37+
#### Prefer JSX to `createElement`.
38+
39+
Ignore this if you're specifically describing `createElement`.
40+
41+
#### Use `const` where possible, otherwise `let`. Don't use `var`.
42+
43+
Ignore this if you're specifically writing about ES5.
44+
45+
#### Don't use ES6 features when equivalent ES5 features have no downsides.
46+
47+
Remember that ES6 is still new to a lot of people. While we use it in many places (`const` / `let`, classes, arrow functions), if the equivalent ES5 code is just as straightforward and readable, consider using it.
48+
49+
In particular, you should prefer named `function` declarations over `const myFunction = () => ...` arrows for top-level functions. However, you *should* use arrow functions where they provide a tangible improvement (such as preserving `this` context inside a component). Consider both sides of the tradeoff when deciding whether to use a new feature.
50+
51+
#### Don't use features that aren't standardized yet.
52+
53+
For example, **don't** write this:
54+
55+
```js
56+
class MyComponent extends React.Component {
57+
state = {value: ''};
58+
handleChange = (e) => {
59+
this.setState({value: e.target.value});
60+
};
61+
}
62+
```
63+
64+
Instead, **do** write this:
65+
66+
```js
67+
class MyComponent extends React.Component {
68+
constructor(props) {
69+
super(props)
70+
this.handleChange = this.handleChange.bind(this);
71+
this.state = {value: ''};
72+
}
73+
handleChange(e) {
74+
this.setState({value: e.target.value});
75+
}
76+
}
77+
```
78+
79+
Ignore this rule if you're specifically describing an experimental proposal. Make sure to mention its experimental nature in the code and in the surrounding text.
80+
81+
### Style
82+
83+
- Use semicolons.
84+
- No space between function names and parens (`method() {}` not `method () {}`).
85+
- When in doubt, use the default style favored by [Prettier](https://prettier.io/playground/).
86+
87+
### Highlighting
88+
89+
Use `js` as the highlighting language in Markdown code blocks:
90+
91+
````
92+
```js
93+
// code
94+
```
95+
````
96+
97+
Sometimes you'll see blocks with numbers.
98+
They tell the website to highlight specific lines.
99+
100+
You can highlight a single line:
101+
102+
````
103+
```js{2}
104+
function hello() {
105+
// this line will get highlighted
106+
}
107+
```
108+
````
109+
110+
A range of lines:
111+
112+
````
113+
```js{2-4}
114+
function hello() {
115+
// these lines
116+
// will get
117+
// highlighted
118+
}
119+
```
120+
````
121+
122+
Or even multiple ranges:
123+
124+
````
125+
```js{2-4,6}
126+
function hello() {
127+
// these lines
128+
// will get
129+
// highlighted
130+
console.log('hello');
131+
// also this one
132+
console.log('there');
133+
}
134+
```
135+
````
136+
137+
Be mindful that if you move some code in an example with highlighting, you also need to update the highlighting.
138+
139+
Don't be afraid to often use highlighting! It is very valuable when you need to focus the reader's attention on a particular detail that's easy to miss.

Diff for: LICENSE.md

-21
This file was deleted.

Diff for: README.md

+14-4
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ This repo contains the source code and documentation powering [reactjs.org](http
99
1. Git
1010
1. Node: install version 8.4 or greater
1111
1. Yarn: See [Yarn website for installation instructions](https://yarnpkg.com/lang/en/docs/install/)
12-
1. A clone of the [reactjs.org repo](https://github.com/reactjs/reactjs.org) on your local machine
1312
1. A fork of the repo (for any contributions)
13+
1. A clone of the [reactjs.org repo](https://github.com/reactjs/reactjs.org) on your local machine
1414

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

@@ -24,6 +24,10 @@ This repo contains the source code and documentation powering [reactjs.org](http
2424

2525
## Contributing
2626

27+
### Guidelines
28+
29+
The documentation is divided into several sections with a different tone and purpose. If you plan to write more than a few sentences, you might find it helpful to get familiar with the [contributing guidelines](https://github.com/reactjs/reactjs.org/blob/master/CONTRIBUTING.md#guidelines-for-text) for the appropriate sections.
30+
2731
### Create a branch
2832

2933
1. `git checkout master` from any folder in your local `reactjs.org` repository
@@ -41,15 +45,21 @@ This repo contains the source code and documentation powering [reactjs.org](http
4145
### Test the change
4246

4347
1. If possible, test any visual changes in all latest versions of common browsers, on both desktop and mobile.
44-
1. Run `yarn check-all` from the project root. (This will run Prettier, ESlint, and Flow.)
48+
1. Run `yarn check-all` from the project root. (This will run Prettier, ESLint, and Flow.)
4549

4650
### Push it
4751

4852
1. `git add -A && git commit -m "My message"` (replacing `My message` with a commit message, such as `Fixed header logo on Android`) to stage and commit your changes
4953
1. `git push my-fork-name the-name-of-my-branch`
5054
1. Go to the [reactjs.org repo](https://github.com/reactjs/reactjs.org) and you should see recently pushed branches.
5155
1. Follow GitHub's instructions.
52-
1. If possible include screenshots of visual changes. A Netlify build will also be automatically created once you make your PR so other people can see your change.
56+
1. If possible, include screenshots of visual changes. A Netlify build will also be automatically created once you make your PR so other people can see your change.
57+
58+
## Translation
59+
60+
If you are interesting in translating `reactjs.org`, please join the Crowdin.
61+
62+
* [Crowdin - React](https://crowdin.com/project/react)
5363

5464
## Troubleshooting
5565

Diff for: content/authors.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,15 @@ acdlite:
77
benigeri:
88
name: Paul Benigeri
99
url: https://github.com/benigeri
10+
bvaughn:
11+
name: Brian Vaughn
12+
url: https://github.com/bvaughn
1013
chenglou:
1114
name: Cheng Lou
1215
url: https://twitter.com/_chenglou
16+
clemmy:
17+
name: Clement Hoang
18+
url: https://twitter.com/c8hoang
1319
Daniel15:
1420
name: Daniel Lo Nigro
1521
url: http://dan.cx/
@@ -63,7 +69,7 @@ sebmarkbage:
6369
url: https://twitter.com/sebmarkbage
6470
sophiebits:
6571
name: Sophie Alpert
66-
url: https://sophiealpert.com
72+
url: https://sophiebits.com/
6773
steveluscher:
6874
name: Steven Luscher
6975
url: https://twitter.com/steveluscher

Diff for: content/blog/2013-06-05-why-react.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ some pretty cool things with it:
8080
(including IE8) and automatically use
8181
[event delegation](http://davidwalsh.name/event-delegate).
8282

83-
Head on over to https://reactjs.org to check out what we have
83+
Head on over to [https://reactjs.org](https://reactjs.org) to check out what we have
8484
built. Our documentation is geared towards building apps with the framework,
8585
but if you are interested in the nuts and bolts
8686
[get in touch](/support.html) with us!

Diff for: content/blog/2014-10-16-react-v0.12-rc1.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ We've also published version `0.12.0-rc1` of the `react` and `react-tools` packa
2222

2323
## React Elements
2424

25-
The biggest conceptual change we made in v0.12 is the move to React Elements. [We talked about this topic in depth earlier this week](/blog/2014/10/14/introducting-react-elements.html). If you haven't already, you should read up on the exciting changes in there!
25+
The biggest conceptual change we made in v0.12 is the move to React Elements. [We talked about this topic in depth earlier this week](/blog/2014/10/14/introducing-react-elements.html). If you haven't already, you should read up on the exciting changes in there!
2626

2727

2828
## JSX Changes

Diff for: content/blog/2015-03-30-community-roundup-26.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Jay Garcia spent a lot of time during the beta working on a NES music player wit
6767

6868
## React Native with Babel and webpack
6969

70-
React Native ships with a custom packager and custom ES6 transforms instead of using what the open source community settled on such as webpack and Babel. The main reason for this is performance – we couldn't get those tools to have sub-second reload time on a large codebase.
70+
React Native ships with a custom packager and custom ES6 transforms instead of using what the open source community settled on such as [webpack](https://webpack.js.org/) and [Babel](https://babeljs.io/). The main reason for this is performance – we couldn't get those tools to have sub-second reload time on a large codebase.
7171

7272
Roman Liutikov found a way to [use webpack and Babel to run on React Native](https://github.com/roman01la/react-native-babel)! In the future, we want to work with those projects to provide cleaner extension mechanisms.
7373

Diff for: content/blog/2015-07-03-react-v0.14-beta-1.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This week, many people in the React community are at [ReactEurope](https://www.r
77

88
With React 0.14, we're continuing to let React mature and to make minor changes as the APIs continue to settle down. I'll talk only about the two largest changes in this blog post; when we publish the final release we'll be sure to update all of our documentation and include a full changelog.
99

10-
You can install the new beta with `npm install [email protected]` and `npm install [email protected]`. As mentioned in [Deprecating react-tools](https://reactjs.org/blog/2015/06/12/deprecating-jstransform-and-react-tools.html), we're no longer updating the react-tools package so this release doesn't include a new version of it. Please try the new version out and let us know what you think, and please do file issues on our GitHub repo if you run into any problems.
10+
You can install the new beta with `npm install [email protected]` and `npm install [email protected]`. As mentioned in [Deprecating react-tools](/blog/2015/06/12/deprecating-jstransform-and-react-tools.html), we're no longer updating the react-tools package so this release doesn't include a new version of it. Please try the new version out and let us know what you think, and please do file issues on our GitHub repo if you run into any problems.
1111

1212
## Two Packages
1313

Diff for: content/blog/2015-12-16-ismounted-antipattern.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ If you use ES6 promises, you may need to wrap your promise in order to make it c
4343

4444
```js
4545
const cancelablePromise = makeCancelable(
46-
new Promise(r => component.setState({...}}))
46+
new Promise(r => component.setState({...}))
4747
);
4848

4949
cancelablePromise

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jscodeshift -t react-codemod/transforms/React-PropTypes-to-prop-types.js <path>
6363

6464
The `propTypes`, `contextTypes`, and `childContextTypes` APIs will work exactly as before. The only change is that the built-in validators now live in a separate package.
6565

66-
You may also consider using [Flow](https://flow.org/) to statically type check your JavaScript code, including [React components](https://flow.org/en/docs/frameworks/react/#setup-flow-with-react-a-classtoc-idtoc-setup-flow-with-react-hreftoc-setup-flow-with-reacta).
66+
You may also consider using [Flow](https://flow.org/) to statically type check your JavaScript code, including [React components](https://flow.org/en/docs/react/components/).
6767

6868
### Migrating from React.createClass
6969

@@ -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.

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

+1-1
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

0 commit comments

Comments
 (0)