Skip to content

Commit cc0c433

Browse files
authored
Merge pull request #43 from reactjs/sync-c024001c
Sync with reactjs.org @ c024001
2 parents b3f34a8 + d46ab0b commit cc0c433

11 files changed

+39
-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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ bị biến đổi. Bạn sẽ cần [babel-plugin-syntax-dynamic-import](https:
107107

108108
> Chú ý:
109109
>
110-
> `React.lazy` và Suspense chưa có sẵn cho server-side rendering. Nếu bạn muốn phân chia code ở những ứng dụng render tại server,
111-
chúng tôi xin giới thiệu [Loadable Components](https://github.com/smooth-code/loadable-components). Nó có [hướng dẫn phân chia code với
112-
server-side rendering](https://github.com/smooth-code/loadable-components/blob/master/packages/server/README.md).
110+
> `React.lazy` và Suspense chưa có sẵn cho server-side rendering. Nếu bạn muốn phân chia code ở những ứng dụng render tại server, chúng tôi xin giới thiệu [Loadable Components](https://github.com/smooth-code/loadable-components). Nó có [hướng dẫn phân chia code với server-side rendering](https://github.com/smooth-code/loadable-components/blob/master/packages/server/README.md).
113111
114112
Chức năng `React.lazy` cho phép bạn render một import động như một component bình thường.
115113

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 @@ The React team primarily recommends these solutions:
3939

4040
[Create React App](https://github.com/facebookincubator/create-react-app) is a comfortable environment for **learning React**, and is the best way to start building **a new [single-page](/docs/glossary.html#single-page-application) application** in React.
4141

42-
It sets up your development environment so that you can use the latest JavaScript features, provides a nice developer experience, and optimizes your app for production. You’ll need to have Node >= 6 and npm >= 5.2 on your machine. To create a project, run:
42+
It sets up your development environment so that you can use the latest JavaScript features, provides a nice developer experience, and optimizes your app for production. You’ll need to have Node >= 8.10 and npm >= 5.6 on your machine. To create a project, run:
4343

4444
```bash
4545
npx create-react-app my-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-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/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)