Skip to content

Commit 4099efe

Browse files
Merge pull request #109 from reactjs/sync-c024001c
Sync with reactjs.org @ c024001
2 parents 73c9f08 + 7fc28bc commit 4099efe

11 files changed

+41
-33
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/create-a-new-react-app.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Zespół Reacta rekomenduje następujące rozwiązania:
4040

4141
[Create React App](http://github.com/facebookincubator/create-react-app) zapewnia bardzo dogodne środowisko pracy sprzyjające **nauce Reacta**. Jest to najlepszy sposób, aby zacząć tworzyć **nową [jednostronicową](/docs/glossary.html#single-page-application) aplikację** w Reakcie.
4242

43-
Środowisko pracy stworzone przez Create React App nie tylko umożliwi ci stosowanie najnowszych funkcjonalności języka JavaScript, lecz także zoptymalizuje twój kod przed oddaniem go do użytku i ogólnie znacznie usprawni twoją pracę. Aby móc skorzystać z tego rozwiązania na swoim komputerze, będziesz potrzebować Node >= 6 oraz npm >= 5.2. Stworzenie projektu umożliwią ci następujące komendy:
43+
Środowisko pracy stworzone przez Create React App nie tylko umożliwi ci stosowanie najnowszych funkcjonalności języka JavaScript, lecz także zoptymalizuje twój kod przed oddaniem go do użytku i ogólnie znacznie usprawni twoją pracę. Aby móc skorzystać z tego rozwiązania na swoim komputerze, będziesz potrzebować Node >= 8.10 oraz npm >= 5.6. Stworzenie projektu umożliwią ci następujące komendy:
4444

4545
```bash
4646
npx create-react-app moja-aplikacja

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-
Istnieje również nowy [skrócony zapis](#short-syntax) do deklarowania fragmentów, jednak nie jest on jeszcze wspierany przez wszystkie popularne narzędzia.
21+
Istnieje również nowy [skrócony zapis](#short-syntax) do deklarowania fragmentów.
2222

2323
## Motywacja {#motivation}
2424

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

114114
Możesz używać `<></>` tak samo, jak innych komponentów. Nie możesz jednak przekazywać do niego klucza (`key`) ani żadnych innych właściwości.
115115

116-
Zwróć uwagę, że **[wiele narzędzi nie posiada jeszcze wsparcia dla tego zapisu](/blog/2017/11/28/react-v16.2.0-fragment-support.html#support-for-fragment-syntax)**. Do czasu jego dodania pisz po prostu `<React.Fragment>`.
117-
118116
### Fragmenty z kluczem {#keyed-fragments}
119117

120118
Fragmenty zadeklarowane jawnie przy użyciu składni `<React.Fragment>` mogą posiadać klucze. Ma to zastosowanie, gdy zechcesz przemapować kolekcję na tablicę fragmentów -- na przykład do stworzenia listy opisów:

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/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 @@ W pierwszej kolejności zakreśl na projekcie wszystkie komponenty (i podkompone
3737

3838
Skąd wiadomo, co powinno być komponentem? Zastosuj te same metody, których używamy tworząc nowe funkcje lub obiekty. Jedną z takich metod jest [Zasada jednej odpowiedzialności](https://pl.wikipedia.org/wiki/Zasada_jednej_odpowiedzialno%C5%9Bci), zgodnie z którą każdy komponent powinien być odpowiedzialny za tylko jedną rzecz. Jeśli komponent nie spełnia tej zasady i odpowiada za więcej rzeczy, należy go rozbić na kilka mniejszych komponentów.
3939

40-
Model danych wyświetlanych użytkownikowi często odpowiada modelowi zawartemu w plikach JSON. Dlatego jeśli właściwie skonstruujesz swój model, twój interfejs użytkownika (a co za tym idzie także twój układ komponentów) zostanie właściwie zmapowany. Wiąże się to z faktem, że interfejsy użytkownika i modele danych zwykle stosują się do tych samych zasad *architektury informacji*. Wszystko to zaś oznacza, że zadanie podziału interfejsu użytkownika na komponenty jest zwykle zadaniem dziecinnie prostym. Po prostu podziel go tak, aby jednemu elementowi twojego modelu danych odpowiadał jeden komponent.
40+
Model danych wyświetlanych użytkownikowi często odpowiada modelowi zawartemu w plikach JSON. Dlatego jeśli właściwie skonstruujesz swój model, twój interfejs użytkownika (a co za tym idzie także twój układ komponentów) zostanie właściwie zmapowany. Wiąże się to z faktem, że interfejsy użytkownika i modele danych zwykle stosują się do tych samych zasad *architektury informacji*. Podziel swój interfejs tak, aby jednemu elementowi twojego modelu danych odpowiadał jeden komponent.
4141

4242
![Wykres komponentów](../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)