Skip to content

Commit 5f2ef48

Browse files
author
Brian Vaughn
committed
Merged master
2 parents 4b6e332 + 30ea17e commit 5f2ef48

File tree

251 files changed

+7952
-1716
lines changed

Some content is hidden

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

251 files changed

+7952
-1716
lines changed

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

.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+
}

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.

README.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ 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

@@ -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
@@ -51,6 +55,12 @@ This repo contains the source code and documentation powering [reactjs.org](http
5155
1. Follow GitHub's instructions.
5256
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.
5357

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)
63+
5464
## Troubleshooting
5565

5666
- `yarn reset` to clear the local cache

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

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!

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

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

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

+4-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ render() {
2121
}
2222
```
2323

24-
In the future, we'll likely add a special fragment syntax to JSX that doesn't require keys.
24+
[Starting with React 16.2.0](/blog/2017/11/28/react-v16.2.0-fragment-support.html), we are adding support for a special fragment syntax to JSX that doesn't require keys.
2525

2626
We've added support for returning strings, too:
2727

@@ -197,12 +197,11 @@ ReactDOM.render(
197197
);
198198
```
199199

200-
React also depends on `requestAnimationFrame` (even in test environments). A simple shim for test environments would be:
200+
React also depends on `requestAnimationFrame` (even in test environments).
201+
You can use the [raf](https://www.npmjs.com/package/raf) package to shim `requestAnimationFrame`:
201202

202203
```js
203-
global.requestAnimationFrame = function(callback) {
204-
setTimeout(callback, 0);
205-
};
204+
import 'raf/polyfill';
206205
```
207206

208207
## Acknowledgments

0 commit comments

Comments
 (0)