Skip to content

Commit 82468f6

Browse files
authored
Merge pull request #151 from reactjs/sync-c024001c
Sync with reactjs.org @ c024001
2 parents a393ac2 + d8c5865 commit 82468f6

10 files changed

+45
-39
lines changed

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

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

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

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

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ React 팀의 추천 방법은 아래와 같습니다
3939

4040
[Create React App](https://github.com/facebookincubator/create-react-app)**React 배우기**에 간편한 환경입니다. 그리고 시작하기에 최고의 방법은 **새로운 [싱글 페이지 애플리케이션](/docs/glossary.html#single-page-application)** 입니다.
4141

42-
이것은 개발 환경을 설정하고, 최신 JavaScript를 사용하게 해주며, 좋은 개발 경험과 프로덕션 앱 최적화를 해줍니다. Node 6 혹은 상위 버전 및 npm 5.2 혹은 상위 버전이 필요합니다. 새로운 프로젝트를 만들기 위해 아래의 명령어를 실행합니다.
42+
이것은 개발 환경을 설정하고, 최신 JavaScript를 사용하게 해주며, 좋은 개발 경험과 프로덕션 앱 최적화를 해줍니다. Node 8.10 혹은 상위 버전 및 npm 5.6 혹은 상위 버전이 필요합니다. 새로운 프로젝트를 만들기 위해 아래의 명령어를 실행합니다.
4343

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

content/docs/fragments.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ render() {
1616
</React.Fragment>
1717
);
1818
}
19-
```
19+
```
2020

21-
이를 선언하는 새로운 [단축 문법](#short-syntax)이 있습니다. 하지만 아직 모든 인기 있는 도구에서 전부 지원하지는 않습니다.
21+
이를 선언하는 새로운 [단축 문법](#short-syntax)이 있습니다.
2222

2323
## 동기 {#motivation}
2424

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

114114
`key` 또는 어트리뷰트를 지원하지 않는다는 것을 빼고 다른 엘리먼트처럼 `<></>`을 사용할 수 있습니다.
115115

116-
주의: **[아직 많은 도구에서 이 단축 문법이 지원이 안 되기 때문에](/blog/2017/11/28/react-v16.2.0-fragment-support.html#support-for-fragment-syntax)** 그전까지는 명시적으로 `<React.Fragmemt>`를 사용해야 하는 것에 주의해야 합니다.
117-
118116
### key가 있는 Fragments {#keyed-fragments}
119117

120118
Fragments에 `key`가 있다면 `<React.Fragment>` 문법으로 명시적으로 선언해야 합니다. 예를 들어 정의 목록을 만들기 위해 컬렉션을 fragments 배열로 매핑하는 사용 사례입니다.

content/docs/hooks-reference.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const [state, setState] = useState(initialState);
3636
상태 유지 값과 그 값을 갱신하는 함수를 반환합니다.
3737

3838
최초로 렌더링을 하는 동안, 반환된 state(`state`)는 첫 번째 전달된 인자(`initialState`)의 값과 같습니다.
39-
39+
4040
`setState` 함수는 state를 갱신할 때 사용합니다. 새 state 값을 받아 컴포넌트 리렌더링을 큐에 등록합니다.
4141

4242
```js
@@ -51,7 +51,7 @@ setState(newState);
5151
5252
#### 함수적 갱신 {#functional-updates}
5353

54-
이전 state를 사용해서 새로운 state를 계산하는 경우 함수를 `setState` 로 전달할 수 있습니다. 그 함수는 이전 값을 받아 갱신된 값을 반환할 것입니다. 여기에 `setState`의 양쪽 형태를 사용한 카운터 컴포넌트의 예가 있습니다.
54+
이전 state를 사용해서 새로운 state를 계산하는 경우 함수를 `setState` 로 전달할 수 있습니다. 그 함수는 이전 값을 받아 갱신된 값을 반환할 것입니다. 여기에 `setState`의 양쪽 형태를 사용한 카운터 컴포넌트의 예가 있습니다.
5555

5656
```js
5757
function Counter({initialCount}) {
@@ -111,7 +111,7 @@ useEffect(didUpdate);
111111

112112
대신에 `useEffect`를 사용하세요. `useEffect`에 전달된 함수는 화면에 렌더링이 완료된 후에 수행되게 될 것입니다. React의 순수한 함수적인 세계에서 명령적인 세계로의 탈출구로 생각하세요.
113113

114-
기본적으로 동작은 모든 렌더링이 완료된 후에 수행됩니다만, [어떤 값이 변경되었을 때만](#conditionally-firing-an-effect) 실행되게 할 수도 있습니다.
114+
기본적으로 동작은 모든 렌더링이 완료된 후에 수행됩니다만, [어떤 값이 변경되었을 때만](#conditionally-firing-an-effect) 실행되게 할 수도 있습니다.
115115

116116
#### effect 정리 {#cleaning-up-an-effect}
117117

@@ -127,15 +127,15 @@ useEffect(() => {
127127
});
128128
```
129129

130-
정리 함수는 메모리 누수 방지를 위해 UI에서 컴포넌트를 제거하기 전에 수행됩니다. 더불어, 만약 컴포넌트가 (그냥 일반적으로 수행하는 것처럼) 여러 번 렌더링 된다면 **다음 effect가 수행되기 전에 이전 effect는 정리됩니다**. 위의 예에서, 매 갱신마다 새로운 구독이 생성된다고 볼 수 있습니다. 갱신마다 불필요한 수행이 발생하는 것을 회피하기 위해서는 다음 절을 참고하세요.
130+
정리 함수는 메모리 누수 방지를 위해 UI에서 컴포넌트를 제거하기 전에 수행됩니다. 더불어, 만약 컴포넌트가 (그냥 일반적으로 수행하는 것처럼) 여러 번 렌더링 된다면 **다음 effect가 수행되기 전에 이전 effect는 정리됩니다**. 위의 예에서, 매 갱신마다 새로운 구독이 생성된다고 볼 수 있습니다. 갱신마다 불필요한 수행이 발생하는 것을 회피하기 위해서는 다음 절을 참고하세요.
131131

132132
#### effect 타이밍 {#timing-of-effects}
133133

134134
`componentDidMount``componentDidUpdate`와는 다르게, `useEffect`로 전달된 함수는 지연 이벤트 동안에 레이아웃 배치와 그리기를 완료한 **** 발생합니다. 이것은 구독이나 이벤트 핸들러를 설정하는 것과 같은 다수의 공통적인 부작용에 적합합니다. 왜냐면 대부분의 작업이 브라우저에서 화면을 업데이트하는 것을 차단해서는 안 되기 때문입니다.
135135

136136
그렇지만, 모든 effect가 지연될 수는 없습니다. 예를 들어 사용자에게 노출되는 DOM 변경은 사용자가 노출된 내용의 불일치를 경험하지 않도록 다음 화면을 다 그리기 이전에 동기화 되어야 합니다. (그 구분이란 개념적으로는 수동적 이벤트 리스너와 능동적 이벤트 리스너의 차이와 유사합니다) 이런 종류의 effect를 위해 React는 [`useLayoutEffect`](#uselayouteffect)라는 추가적인 Hook을 제공합니다. 그것은 `useEffect`와 동일한 시그니처를 가지고 있고 그것이 수행될 때에만 차이가 납니다.
137137

138-
`useEffect`는 브라우저 화면이 다 그려질 때까지 지연됩니다만, 다음 어떤 새로운 렌더링이 발생하기 이전에 발생하는 것도 보장합니다. React는 새로운 갱신을 시작하기 전에 이전 렌더링을 항상 완료하게 됩니다.
138+
`useEffect`는 브라우저 화면이 다 그려질 때까지 지연됩니다만, 다음 어떤 새로운 렌더링이 발생하기 이전에 발생하는 것도 보장합니다. React는 새로운 갱신을 시작하기 전에 이전 렌더링을 항상 완료하게 됩니다.
139139

140140
#### 조건부 effect 발생 {#conditionally-firing-an-effect}
141141

@@ -261,7 +261,7 @@ function Counter() {
261261

262262
초기 state를 조금 지연해서 생성할 수도 있습니다. 이를 위해서는 `init` 함수를 세 번째 인자로 전달합니다. 초기 state는 `init(initialArg)`에 설정될 것입니다.
263263

264-
이것은 reducer 외부에서 초기 state를 계산하는 로직을 추출할 수 있도록 합니다. 또한, 어떤 행동에 대한 대응으로 나중에 state를 재설정하는 데에도 유용합니다.
264+
이것은 reducer 외부에서 초기 state를 계산하는 로직을 추출할 수 있도록 합니다. 또한, 어떤 행동에 대한 대응으로 나중에 state를 재설정하는 데에도 유용합니다.
265265

266266
```js{1-3,11-12,19,24}
267267
function init(initialCount) {
@@ -407,7 +407,7 @@ FancyInput = forwardRef(FancyInput);
407407
```
408408

409409
위의 예제에서 `<FancyInput ref={fancyInputRef} />`를 렌더링한 부모 컴포넌트는 `fancyInputRef.current.focus()`를 호출할 수 있습니다.
410-
410+
411411
### `useLayoutEffect` {#uselayouteffect}
412412

413413
이 함수의 시그니처는 `useEffect`와 동일하긴 한데, 모든 DOM 변경 후에 동기적으로 발생합니다. 이것은 DOM에서 레이아웃을 읽고 동기적으로 리렌더링하는 경우에 사용하세요. `useLayoutEffect`의 내부에 예정된 갱신은 브라우저가 화면을 그리기 이전 시점에 동기적으로 수행될 것입니다.

content/docs/how-to-contribute.md

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

+23-24
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

+6
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ MyComponent.propTypes = {
8282
color: PropTypes.string,
8383
fontSize: PropTypes.number
8484
}),
85+
86+
// An object with warnings on extra properties
87+
optionalObjectWithStrictShape: PropTypes.exact({
88+
name: PropTypes.string,
89+
quantity: PropTypes.number
90+
}),
8591

8692
// 위에 있는 것 모두 `isRequired`와 연결하여 prop가 제공되지 않았을 때
8793
// 경고가 보이도록 할 수 있습니다.

0 commit comments

Comments
 (0)