You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/blog/2018-03-27-update-on-async-rendering.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -134,7 +134,7 @@ Here is an example of a component that uses the legacy `componentWillReceiveProp
134
134
135
135
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.
136
136
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:
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`.
Copy file name to clipboardExpand all lines: content/blog/2019-02-23-is-react-translated-yet.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -39,7 +39,7 @@ This approach appealed to us for several reasons:
39
39
* It encouraged active maintainers for each repo to ensure quality.
40
40
* Contributors already understand GitHub as a platform and are motivated to contribute directly to the React organization.
41
41
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.
43
43
44
44
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!
Copy file name to clipboardExpand all lines: content/docs/code-splitting.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -115,7 +115,7 @@ parse the dynamic import syntax but is not transforming it. For that you will ne
115
115
116
116
> Note:
117
117
>
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).
119
119
120
120
The `React.lazy` function lets you render a dynamic import as a regular component.
Copy file name to clipboardExpand all lines: content/docs/create-a-new-react-app.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -39,7 +39,7 @@ Il team di React raccomanda prima di tutto queste soluzioni:
39
39
40
40
[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.
41
41
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:
Copy file name to clipboardExpand all lines: content/docs/fragments.md
+1-3Lines changed: 1 addition & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ render() {
18
18
}
19
19
```
20
20
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.
22
22
23
23
## Motivation {#motivation}
24
24
@@ -113,8 +113,6 @@ class Columns extends React.Component {
113
113
114
114
You can use `<></>` the same way you'd use any other element except that it doesn't support keys or attributes.
115
115
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
-
118
116
### Keyed Fragments {#keyed-fragments}
119
117
120
118
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:
Copy file name to clipboardExpand all lines: content/docs/hooks-reference.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -244,7 +244,7 @@ function Counter() {
244
244
245
245
#### Specifying the initial state {#specifying-the-initial-state}
246
246
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:
Copy file name to clipboardExpand all lines: content/docs/optimizing-performance.md
+23-24Lines changed: 23 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -51,14 +51,14 @@ Remember that only React files ending with `.production.min.js` are suitable for
51
51
52
52
### Brunch {#brunch}
53
53
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:
55
55
56
56
```
57
57
# If you use npm
58
-
npm install --save-dev uglify-js-brunch
58
+
npm install --save-dev terser-brunch
59
59
60
60
# If you use Yarn
61
-
yarn add --dev uglify-js-brunch
61
+
yarn add --dev terser-brunch
62
62
```
63
63
64
64
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:
75
75
76
76
```
77
77
# If you use npm
78
-
npm install --save-dev envify uglify-js uglifyify
78
+
npm install --save-dev envify terser uglifyify
79
79
80
80
# If you use Yarn
81
-
yarn add --dev envify uglify-js uglifyify
81
+
yarn add --dev envify terser uglifyify
82
82
```
83
83
84
84
To create a production build, make sure that you add these transforms **(the order matters)**:
85
85
86
86
* The [`envify`](https://github.com/hughsk/envify) transform ensures the right build environment is set. Make it global (`-g`).
87
87
* 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)).
89
89
90
90
For example:
91
91
92
92
```
93
93
browserify ./index.js \
94
94
-g [ envify --NODE_ENV production ] \
95
95
-g uglifyify \
96
-
| uglifyjs --compress --mangle > ./bundle.js
96
+
| terser --compress --mangle > ./bundle.js
97
97
```
98
98
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
-
104
99
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.
105
100
106
101
### Rollup {#rollup}
107
102
108
103
For the most efficient Rollup production build, install a few plugins:
For a complete setup example [see this gist](https://gist.github.com/Rich-Harris/cb14f4bc0670c47d00d191565be36bf0).
137
132
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.
139
134
140
135
### webpack {#webpack}
141
136
@@ -144,18 +139,22 @@ Remember that you only need to do this for production builds. You shouldn't appl
minimizer: [newTerserPlugin({ /* additional options here */ })],
151
+
},
152
+
};
154
153
```
155
154
156
155
You can learn more about this in [webpack documentation](https://webpack.js.org/guides/production/).
157
156
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.
159
158
160
159
## Profiling Components with the Chrome Performance Tab {#profiling-components-with-the-chrome-performance-tab}
Copy file name to clipboardExpand all lines: content/docs/thinking-in-react.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,7 @@ La prima cosa da fare è disegnare rettangoli attorno ad ogni componente (e sott
37
37
38
38
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.
39
39
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.
41
41
42
42

0 commit comments