Skip to content

Commit 2e79e76

Browse files
Merge pull request #160 from reactjs/sync-c024001c
Sync with reactjs.org @ c024001
2 parents 00276ec + 8770d06 commit 2e79e76

13 files changed

+43
-35
lines changed

content/blog/2018-03-27-update-on-async-rendering.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ Here is an example of a component that uses the legacy `componentWillReceiveProp
134134

135135
Although the above code is not problematic in itself, the `componentWillReceiveProps` lifecycle is often mis-used in ways that _do_ present problems. Because of this, the method will be deprecated.
136136

137-
As of version 16.3, the recommended way to update `state` in response to `props` changes is with the new `static getDerivedStateFromProps` lifecycle. (That lifecycle is called when a component is created and each time it receives new props):
137+
As of version 16.3, the recommended way to update `state` in response to `props` changes is with the new `static getDerivedStateFromProps` lifecycle. It is called when a component is created and each time it re-renders due to changes to props or state:
138138
`embed:update-on-async-rendering/updating-state-from-props-after.js`
139139

140140
You may notice in the example above that `props.currentRow` is mirrored in state (as `state.lastRow`). This enables `getDerivedStateFromProps` to access the previous props value in the same way as is done in `componentWillReceiveProps`.

content/blog/2019-02-23-is-react-translated-yet.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ This approach appealed to us for several reasons:
3939
* It encouraged active maintainers for each repo to ensure quality.
4040
* Contributors already understand GitHub as a platform and are motivated to contribute directly to the React organization.
4141

42-
We started of with an initial trial period of three languages: Spanish, Japanese, and Simplified Chinese. This allowed us to work out any kinks in our process and make sure future translations are set up for success. I wanted to give the translation teams freedom to choose whatever tools they felt comfortable with. The only requirement is a [checklist](https://github.com/reactjs/reactjs.org-translation/blob/master/PROGRESS.template.md) that outlines the order of importance for translating pages.
42+
We started off with an initial trial period of three languages: Spanish, Japanese, and Simplified Chinese. This allowed us to work out any kinks in our process and make sure future translations are set up for success. I wanted to give the translation teams freedom to choose whatever tools they felt comfortable with. The only requirement is a [checklist](https://github.com/reactjs/reactjs.org-translation/blob/master/PROGRESS.template.md) that outlines the order of importance for translating pages.
4343

4444
After the trial period, we were ready to accept more languages. I created [a script](https://github.com/reactjs/reactjs.org-translation/blob/master/scripts/create.js) to automate the creation of the new language repo, and a site, [Is React Translated Yet?](https://isreacttranslatedyet.com), to track progress on the different translations. We started *10* new translations on our first day alone!
4545

content/community/courses.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ permalink: community/courses.html
2222

2323
- [Free React Bootcamp](https://tylermcginnis.com/free-react-bootcamp/) - Recordings from three days of a free online React bootcamp.
2424

25+
- [Scrimba: Learn React for free](https://scrimba.com/g/glearnreact) - 48 hands-on video tutorials building react apps.
26+
2527
## Paid Courses {#paid-courses}
2628

2729
- [Egghead.io](https://egghead.io/browse/frameworks/react) - Short instructional videos on React and many other topics.

content/community/meetups.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Do you have a local React.js meetup? Add it here! (Please keep the list alphabet
6969
* [Bangalore](https://www.meetup.com/ReactJS-Bangalore/)
7070
* [Chennai](https://www.meetup.com/React-Chennai/)
7171
* [Delhi NCR](https://www.meetup.com/React-Delhi-NCR/)
72+
* [Jaipur](https://www.meetup.com/JaipurJS-Developer-Meetup/)
7273

7374
## Ireland {#ireland}
7475
* [Dublin](https://www.meetup.com/ReactJS-Dublin/)

content/docs/code-splitting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ parse the dynamic import syntax but is not transforming it. For that you will ne
115115

116116
> Note:
117117
>
118-
> `React.lazy` and Suspense is not yet available for server-side rendering. If you want to do code-splitting in a server rendered app, we recommend [Loadable Components](https://github.com/smooth-code/loadable-components). It has a nice [guide for bundle splitting with server-side rendering](https://github.com/smooth-code/loadable-components/blob/master/packages/server/README.md).
118+
> `React.lazy` and Suspense are not yet available for server-side rendering. If you want to do code-splitting in a server rendered app, we recommend [Loadable Components](https://github.com/smooth-code/loadable-components). It has a nice [guide for bundle splitting with server-side rendering](https://github.com/smooth-code/loadable-components/blob/master/packages/server/README.md).
119119
120120
The `React.lazy` function lets you render a dynamic import as a regular component.
121121

content/docs/create-a-new-react-app.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Il team di React raccomanda prima di tutto queste soluzioni:
3939

4040
[Create React App](https://github.com/facebookincubator/create-react-app) è un ambiente confortevole per **imparare React**, ed è il modo migliore per iniziare a costruire **una nuova applicazione [single-page](/docs/glossary.html#single-page-application)** in React.
4141

42-
Si occupa di configurare il tuo ambiente di sviluppo in modo da poter utilizzare le caratteristiche più recenti di JavaScript, fornisce un'ottima esperienza di sviluppo e ottimizza la tua applicazione per la produzione. Avrai bisogno di avere installato Node >= 6 e npm >= 5.2 nella tua macchina. Per creare un progetto, esegui:
42+
Si occupa di configurare il tuo ambiente di sviluppo in modo da poter utilizzare le caratteristiche più recenti di JavaScript, fornisce un'ottima esperienza di sviluppo e ottimizza la tua applicazione per la produzione. Avrai bisogno di avere installato Node >= 8.10 e npm >= 5.6 nella tua macchina. Per creare un progetto, esegui:
4343

4444
```bash
4545
npx create-react-app mia-app

content/docs/fragments.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ render() {
1818
}
1919
```
2020

21-
There is also a new [short syntax](#short-syntax) for declaring them, but it isn't supported by all popular tools yet.
21+
There is also a new [short syntax](#short-syntax) for declaring them.
2222

2323
## Motivation {#motivation}
2424

@@ -113,8 +113,6 @@ class Columns extends React.Component {
113113

114114
You can use `<></>` the same way you'd use any other element except that it doesn't support keys or attributes.
115115

116-
Note that **[many tools don't support it yet](/blog/2017/11/28/react-v16.2.0-fragment-support.html#support-for-fragment-syntax)** so you might want to explicitly write `<React.Fragment>` until the tooling catches up.
117-
118116
### Keyed Fragments {#keyed-fragments}
119117

120118
Fragments declared with the explicit `<React.Fragment>` syntax may have keys. A use case for this is mapping a collection to an array of fragments -- for example, to create a description list:

content/docs/hooks-faq.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,14 +610,16 @@ function ProductPage({ productId }) {
610610

611611
This also allows you to handle out-of-order responses with a local variable inside the effect:
612612

613-
```js{2,6,8}
613+
```js{2,6,10}
614614
useEffect(() => {
615615
let ignore = false;
616616
async function fetchProduct() {
617617
const response = await fetch('http://myapi/product/' + productId);
618618
const json = await response.json();
619619
if (!ignore) setProduct(json);
620620
}
621+
622+
fetchProduct();
621623
return () => { ignore = true };
622624
}, [productId]);
623625
```

content/docs/hooks-reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ function Counter() {
244244
245245
#### Specifying the initial state {#specifying-the-initial-state}
246246

247-
There’s two different ways to initialize `useReducer` state. You may choose either one depending on the use case. The simplest way to pass the initial state as a second argument:
247+
There are two different ways to initialize `useReducer` state. You may choose either one depending on the use case. The simplest way is to pass the initial state as a second argument:
248248

249249
```js{3}
250250
const [state, dispatch] = useReducer(

content/docs/how-to-contribute.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe
5050
### How to Get in Touch {#how-to-get-in-touch}
5151

5252
* IRC: [#reactjs on freenode](https://webchat.freenode.net/?channels=reactjs)
53-
* Discussion forum: [discuss.reactjs.org](https://discuss.reactjs.org/)
53+
* [Discussion forums](https://reactjs.org/community/support.html#popular-discussion-forums)
5454

5555
There is also [an active community of React users on the Discord chat platform](https://www.reactiflux.com/) in case you need help with React.
5656

content/docs/optimizing-performance.md

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ Remember that only React files ending with `.production.min.js` are suitable for
5151

5252
### Brunch {#brunch}
5353

54-
For the most efficient Brunch production build, install the [`uglify-js-brunch`](https://github.com/brunch/uglify-js-brunch) plugin:
54+
For the most efficient Brunch production build, install the [`terser-brunch`](https://github.com/brunch/terser-brunch) plugin:
5555

5656
```
5757
# If you use npm
58-
npm install --save-dev uglify-js-brunch
58+
npm install --save-dev terser-brunch
5959
6060
# If you use Yarn
61-
yarn add --dev uglify-js-brunch
61+
yarn add --dev terser-brunch
6262
```
6363

6464
Then, to create a production build, add the `-p` flag to the `build` command:
@@ -75,51 +75,46 @@ For the most efficient Browserify production build, install a few plugins:
7575

7676
```
7777
# If you use npm
78-
npm install --save-dev envify uglify-js uglifyify
78+
npm install --save-dev envify terser uglifyify
7979
8080
# If you use Yarn
81-
yarn add --dev envify uglify-js uglifyify
81+
yarn add --dev envify terser uglifyify
8282
```
8383

8484
To create a production build, make sure that you add these transforms **(the order matters)**:
8585

8686
* The [`envify`](https://github.com/hughsk/envify) transform ensures the right build environment is set. Make it global (`-g`).
8787
* The [`uglifyify`](https://github.com/hughsk/uglifyify) transform removes development imports. Make it global too (`-g`).
88-
* Finally, the resulting bundle is piped to [`uglify-js`](https://github.com/mishoo/UglifyJS2) for mangling ([read why](https://github.com/hughsk/uglifyify#motivationusage)).
88+
* Finally, the resulting bundle is piped to [`terser`](https://github.com/terser-js/terser) for mangling ([read why](https://github.com/hughsk/uglifyify#motivationusage)).
8989

9090
For example:
9191

9292
```
9393
browserify ./index.js \
9494
-g [ envify --NODE_ENV production ] \
9595
-g uglifyify \
96-
| uglifyjs --compress --mangle > ./bundle.js
96+
| terser --compress --mangle > ./bundle.js
9797
```
9898

99-
>**Note:**
100-
>
101-
>The package name is `uglify-js`, but the binary it provides is called `uglifyjs`.<br>
102-
>This is not a typo.
103-
10499
Remember that you only need to do this for production builds. You shouldn't apply these plugins in development because they will hide useful React warnings, and make the builds much slower.
105100

106101
### Rollup {#rollup}
107102

108103
For the most efficient Rollup production build, install a few plugins:
109104

110-
```
105+
```bash
111106
# If you use npm
112-
npm install --save-dev rollup-plugin-commonjs rollup-plugin-replace rollup-plugin-uglify
107+
npm install --save-dev rollup-plugin-commonjs rollup-plugin-replace rollup-plugin-terser
113108

114109
# If you use Yarn
115-
yarn add --dev rollup-plugin-commonjs rollup-plugin-replace rollup-plugin-uglify
110+
yarn add --dev rollup-plugin-commonjs rollup-plugin-replace rollup-plugin-terser
116111
```
117112

118113
To create a production build, make sure that you add these plugins **(the order matters)**:
119114

120115
* The [`replace`](https://github.com/rollup/rollup-plugin-replace) plugin ensures the right build environment is set.
121116
* The [`commonjs`](https://github.com/rollup/rollup-plugin-commonjs) plugin provides support for CommonJS in Rollup.
122-
* The [`uglify`](https://github.com/TrySound/rollup-plugin-uglify) plugin compresses and mangles the final bundle.
117+
* The [`terser`](https://github.com/TrySound/rollup-plugin-terser) plugin compresses and mangles the final bundle.
123118

124119
```js
125120
plugins: [
@@ -128,14 +123,14 @@ plugins: [
128123
'process.env.NODE_ENV': JSON.stringify('production')
129124
}),
130125
require('rollup-plugin-commonjs')(),
131-
require('rollup-plugin-uglify')(),
126+
require('rollup-plugin-terser')(),
132127
// ...
133128
]
134129
```
135130

136131
For a complete setup example [see this gist](https://gist.github.com/Rich-Harris/cb14f4bc0670c47d00d191565be36bf0).
137132

138-
Remember that you only need to do this for production builds. You shouldn't apply the `uglify` plugin or the `replace` plugin with `'production'` value in development because they will hide useful React warnings, and make the builds much slower.
133+
Remember that you only need to do this for production builds. You shouldn't apply the `terser` plugin or the `replace` plugin with `'production'` value in development because they will hide useful React warnings, and make the builds much slower.
139134

140135
### webpack {#webpack}
141136

@@ -144,18 +139,22 @@ Remember that you only need to do this for production builds. You shouldn't appl
144139
>If you're using Create React App, please follow [the instructions above](#create-react-app).<br>
145140
>This section is only relevant if you configure webpack directly.
146141
147-
For the most efficient webpack production build, make sure to include these plugins in your production configuration:
142+
Webpack v4+ will minify your code by default in production mode.
148143

149144
```js
150-
new webpack.DefinePlugin({
151-
'process.env.NODE_ENV': JSON.stringify('production')
152-
}),
153-
new webpack.optimize.UglifyJsPlugin()
145+
const TerserPlugin = require('terser-webpack-plugin');
146+
147+
module.exports = {
148+
mode: 'production'
149+
optimization: {
150+
minimizer: [new TerserPlugin({ /* additional options here */ })],
151+
},
152+
};
154153
```
155154

156155
You can learn more about this in [webpack documentation](https://webpack.js.org/guides/production/).
157156

158-
Remember that you only need to do this for production builds. You shouldn't apply `UglifyJsPlugin` or `DefinePlugin` with `'production'` value in development because they will hide useful React warnings, and make the builds much slower.
157+
Remember that you only need to do this for production builds. You shouldn't apply `TerserPlugin` in development because it will hide useful React warnings, and make the builds much slower.
159158

160159
## Profiling Components with the Chrome Performance Tab {#profiling-components-with-the-chrome-performance-tab}
161160

content/docs/thinking-in-react.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ La prima cosa da fare è disegnare rettangoli attorno ad ogni componente (e sott
3737

3838
Ma come fare a sapere cosa deve essere un componente a se stante? Usa le stesse tecniche che usi per decidere se devi creare una nuova funzione od un oggetto. Una di queste tecniche è il [principio di singola responsabilità](https://it.wikipedia.org/wiki/Principio_di_singola_responsabilit%C3%A0), che dice che un componente dovrebbe idealmente occuparsi di una cosa soltanto. Nel caso in cui un componente diventi troppo grande e complesso, dovrebbe essere decomposto in sotto-componenti più piccoli e semplici.
3939

40-
Dato che ti ritroverai spesso a dover presentare all'utente dei modelli dati JSON, noterai che se tali modelli sono stati definiti correttamente, la tua UI (e di conseguenza la struttura della gerarchia dei tuoi componenti) corrisponderanno. Ciò avviene perché entrambe tendono ad aderire alla stessa *architettura dell'informazione*, il che rende la separazione della tua UI in componenti talvolta estremamente semplice. Basta solo rappresentare ogni parte del tuo modello dati con esattamente un componente.
40+
Dato che ti ritroverai spesso a dover presentare all'utente dei modelli dati JSON, noterai che se tali modelli sono stati definiti correttamente, la tua UI (e di conseguenza la struttura della gerarchia dei tuoi componenti) corrisponderanno. Ciò avviene perché entrambe tendono ad aderire alla stessa *architettura dell'informazione*. Separa la tua UI in componenti, dove ognuno di essi corrisponde ad una parte del modello dati.
4141

4242
![Diagramma dei componenti](../images/blog/thinking-in-react-components.png)
4343

content/docs/typechecking-with-proptypes.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ MyComponent.propTypes = {
8383
color: PropTypes.string,
8484
fontSize: PropTypes.number
8585
}),
86+
87+
// An object with warnings on extra properties
88+
optionalObjectWithStrictShape: PropTypes.exact({
89+
name: PropTypes.string,
90+
quantity: PropTypes.number
91+
}),
8692

8793
// You can chain any of the above with `isRequired` to make sure a warning
8894
// is shown if the prop isn't provided.

0 commit comments

Comments
 (0)