Skip to content

Commit 7b70315

Browse files
authored
Merge pull request #209 from reactjs/sync-2ab1ca50
Sync with reactjs.org @ 2ab1ca5
2 parents 970a44f + a7bd2f7 commit 7b70315

18 files changed

+245
-30
lines changed

content/authors.yml

+3
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ steveluscher:
7676
tesseralis:
7777
name: Nat Alison
7878
url: https://twitter.com/tesseralis
79+
threepointone:
80+
name: Sunil Pai
81+
url: https://twitter.com/threepointone
7982
timer:
8083
name: Joe Haddad
8184
url: https://twitter.com/timer150

content/blog/2015-09-02-new-react-developer-tools.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ It contains a handful of new features, including:
2020

2121
## Installation {#installation}
2222

23-
Download the new devtools from the [Chrome Web Store](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi) and on [Firefox Add-ons](https://addons.mozilla.org/en-US/firefox/addon/react-devtools/) for Firefox. If you're developing using React, we highly recommend installing these devtools.
23+
Download the new devtools from the [Chrome Web Store](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi), [Firefox Add-ons](https://addons.mozilla.org/en-US/firefox/addon/react-devtools/) for Firefox, and [Microsoft Edge Addons](https://microsoftedge.microsoft.com/addons/detail/gpphkfbcpidddadnkolkpfckpihlkkil) for Edge. If you're developing using React, we highly recommend installing these devtools.
2424

2525
If you already have the Chrome extension installed, it should autoupdate within the next week. You can also head to `chrome://extensions` and click "Update extensions now" if you'd like to get the new version today. If you installed the devtools beta, please remove it and switch back to the version from the store to make sure you always get the latest updates and bug fixes.
2626

27-
If you run into any issues, please post them on our [react-devtools GitHub repo](https://github.com/facebook/react-devtools).
27+
If you run into any issues, please post them on the [React GitHub repo](https://github.com/facebook/react).
+209
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
---
2+
title: "React v16.13.0"
3+
author: [threepointone]
4+
redirect_from:
5+
- "blog/2020/03/02/react-v16.13.0.html"
6+
---
7+
8+
Today we are releasing React 16.13.0. It contains bugfixes and new deprecation warnings to help prepare for a future major release.
9+
10+
## New Warnings {#new-warnings}
11+
12+
### Warnings for some updates during render {#warnings-for-some-updates-during-render}
13+
14+
A React component should not cause side effects in other components during rendering.
15+
16+
It is supported to call `setState` during render, but [only for *the same component*](/docs/hooks-faq.html#how-do-i-implement-getderivedstatefromprops). If you call `setState` during a render on a different component, you will now see a warning:
17+
18+
```
19+
Warning: Cannot update a component from inside the function body of a different component.
20+
```
21+
22+
**This warning will help you find application bugs caused by unintentional state changes.** In the rare case that you intentionally want to change the state of another component as a result of rendering, you can wrap the `setState` call into `useEffect`.
23+
24+
### Warnings for conflicting style rules
25+
26+
When dynamically applying a `style` that contains longhand and shorthand versions of CSS properties, particular combinations of updates can cause inconsistent styling. For example:
27+
28+
```js
29+
<div style={toggle ?
30+
{ background: 'blue', backgroundColor: 'red' } :
31+
{ backgroundColor: 'red' }
32+
}>
33+
...
34+
</div>
35+
```
36+
37+
You might expect this `<div>` to always have a red background, no matter the value of `toggle`. However, on alternating the value of `toggle` between `true` and `false`, the background color start as `red`, then alternates between `transparent` and `blue`, [as you can see in this demo](https://codesandbox.io/s/suspicious-sunset-g3jub).
38+
39+
**React now detects conflicting style rules and logs a warning.** To fix the issue, don't mix shorthand and longhand versions of the same CSS property in the `style` prop.
40+
41+
### Warnings for some deprecated string refs {#warnings-for-some-deprecated-string-refs}
42+
43+
[String Refs is an old legacy API](/docs/refs-and-the-dom.html#legacy-api-string-refs) which is discouraged and is going to be deprecated in the future:
44+
45+
```js
46+
<Button ref="myRef" />
47+
```
48+
49+
(Don't confuse String Refs with refs in general, which **remain fully supported**.)
50+
51+
In the future, we will provide an automated script (a "codemod") to migrate away from String Refs. However, some rare cases can't be migrated automatically. This release adds a new warning **only for those cases** in advance of the deprecation.
52+
53+
For example, it will fire if you use String Refs together with the Render Prop pattern:
54+
55+
```jsx
56+
class ClassWithRenderProp extends React.Component {
57+
componentDidMount() {
58+
doSomething(this.refs.myRef);
59+
}
60+
render() {
61+
return this.props.children();
62+
}
63+
}
64+
65+
class ClassParent extends React.Component {
66+
render() {
67+
return (
68+
<ClassWithRenderProp>
69+
{() => <Button ref="myRef" />}
70+
</ClassWithRenderProp>
71+
);
72+
}
73+
}
74+
```
75+
76+
Code like this often indicates bugs. (You might expect the ref to be available on `ClassParent`, but instead it gets placed on `ClassWithRenderProp`).
77+
78+
**You most likely don't have code like this**. If you do and it is intentional, convert it to [`React.createRef()`](/docs/refs-and-the-dom.html#creating-refs) instead:
79+
80+
```jsx
81+
class ClassWithRenderProp extends React.Component {
82+
myRef = React.createRef();
83+
componentDidMount() {
84+
doSomething(this.myRef.current);
85+
}
86+
render() {
87+
return this.props.children(this.myRef);
88+
}
89+
}
90+
91+
class ClassParent extends React.Component {
92+
render() {
93+
return (
94+
<ClassWithRenderProp>
95+
{myRef => <Button ref={myRef} />}
96+
</ClassWithRenderProp>
97+
);
98+
}
99+
}
100+
```
101+
102+
> Note
103+
>
104+
> To see this warning, you need to have the [babel-plugin-transform-react-jsx-self](https://babeljs.io/docs/en/babel-plugin-transform-react-jsx-self) installed in your Babel plugins. It must _only_ be enabled in development mode.
105+
>
106+
> If you use Create React App or have the "react" preset with Babel 7+, you already have this plugin installed by default.
107+
108+
### Deprecating `React.createFactory` {#deprecating-reactcreatefactory}
109+
110+
[`React.createFactory`](/docs/react-api.html#createfactory) is a legacy helper for creating React elements. This release adds a deprecation warning to the method. It will be removed in a future major version.
111+
112+
Replace usages of `React.createFactory` with regular JSX. Alternately, you can copy and paste this one-line helper or publish it as a library:
113+
114+
```jsx
115+
let createFactory = type => React.createElement.bind(null, type);
116+
```
117+
118+
It does exactly the same thing.
119+
120+
### Deprecating `ReactDOM.unstable_createPortal` in favor of `ReactDOM.createPortal` {#deprecating-reactdomunstable_createportal-in-favor-of-reactdomcreateportal}
121+
122+
When React 16 was released, `createPortal` became an officially supported API.
123+
124+
However, we kept `unstable_createPortal` as a supported alias to keep the few libraries that adopted it working. We are now deprecating the unstable alias. Use `createPortal` directly instead of `unstable_createPortal`. It has exactly the same signature.
125+
126+
## Other Improvements {#other-improvements}
127+
128+
### Component stacks in hydration warnings {#component-stacks-in-hydration-warnings}
129+
130+
React adds component stacks to its development warnings, enabling developers to isolate bugs and debug their programs. This release adds component stacks to a number of development warnings that didn't previously have them. As an example, consider this hydration warning from the previous versions:
131+
132+
![A screenshot of the console warning, simply stating the nature of the hydration mismatch: "Warning: Expected server HTML to contain a matching div in div."](../images/blog/react-v16.13.0/hydration-warning-before.png)
133+
134+
While it's pointing out an error with the code, it's not clear where the error exists, and what to do next. This release adds a component stack to this warning, which makes it look like this:
135+
136+
![A screenshot of the console warning, stating the nature of the hydration mismatch, but also including a component stack : "Warning: Expected server HTML to contain a matching div in div, in div (at pages/index.js:4)..."](../images/blog/react-v16.13.0/hydration-warning-after.png)
137+
138+
This makes it clear where the problem is, and lets you locate and fix the bug faster.
139+
140+
### Notable bugfixes {#notable-bugfixes}
141+
142+
This release contains a few other notable improvements:
143+
144+
- In Strict Development Mode, React calls lifecycle methods twice to flush out any possible unwanted side effects. This release adds that behaviour to `shouldComponentUpdate`. This shouldn't affect most code, unless you have side effects in `shouldComponentUpdate`. To fix this, move the code with side effects into `componentDidUpdate`.
145+
146+
- In Strict Development Mode, the warnings for usage of the legacy context API didn't include the stack for the component that triggered the warning. This release adds the missing stack to the warning.
147+
148+
- `onMouseEnter` now doesn't trigger on disabled `<button>` elements.
149+
150+
- ReactDOM was missing a `version` export since we published v16. This release adds it back. We don't recommend using it in your application logic, but it's useful when debugging issues with mismatching / multiple versions of ReactDOM on the same page.
151+
152+
We’re thankful to all the contributors who helped surface and fix these and other issues. You can find the full changelog [below](#changelog).
153+
154+
## Installation {#installation}
155+
156+
### React {#react}
157+
158+
React v16.13.0 is available on the npm registry.
159+
160+
To install React 16 with Yarn, run:
161+
162+
```bash
163+
yarn add react@^16.13.0 react-dom@^16.13.0
164+
```
165+
166+
To install React 16 with npm, run:
167+
168+
```bash
169+
npm install --save react@^16.13.0 react-dom@^16.13.0
170+
```
171+
172+
We also provide UMD builds of React via a CDN:
173+
174+
```html
175+
<script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
176+
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
177+
```
178+
179+
Refer to the documentation for [detailed installation instructions](/docs/installation.html).
180+
181+
## Changelog {#changelog}
182+
183+
### React {#react}
184+
185+
- Warn when a string ref is used in a manner that's not amenable to a future codemod ([@lunaruan](https://github.com/lunaruan) in [#17864](https://github.com/facebook/react/pull/17864))
186+
- Deprecate `React.createFactory()` ([@trueadm](https://github.com/trueadm) in [#17878](https://github.com/facebook/react/pull/17878))
187+
188+
### React DOM {#react-dom}
189+
190+
- Warn when changes in `style` may cause an unexpected collision ([@sophiebits](https://github.com/sophiebits) in [#14181](https://github.com/facebook/react/pull/14181), [#18002](https://github.com/facebook/react/pull/18002))
191+
- Warn when a function component is updated during another component's render phase ([@acdlite](<(https://github.com/acdlite)>) in [#17099](https://github.com/facebook/react/pull/17099))
192+
- Deprecate `unstable_createPortal` ([@trueadm](https://github.com/trueadm) in [#17880](https://github.com/facebook/react/pull/17880))
193+
- Fix `onMouseEnter` being fired on disabled buttons ([@AlfredoGJ](https://github.com/AlfredoGJ) in [#17675](https://github.com/facebook/react/pull/17675))
194+
- Call `shouldComponentUpdate` twice when developing in `StrictMode` ([@bvaughn](https://github.com/bvaughn) in [#17942](https://github.com/facebook/react/pull/17942))
195+
- Add `version` property to ReactDOM ([@ealush](https://github.com/ealush) in [#15780](https://github.com/facebook/react/pull/15780))
196+
- Don't call `toString()` of `dangerouslySetInnerHTML` ([@sebmarkbage](https://github.com/sebmarkbage) in [#17773](https://github.com/facebook/react/pull/17773))
197+
- Show component stacks in more warnings ([@gaearon](https://github.com/gaearon) in [#17922](https://github.com/facebook/react/pull/17922), [#17586](https://github.com/facebook/react/pull/17586))
198+
199+
### Concurrent Mode (Experimental) {#concurrent-mode-experimental}
200+
201+
- Warn for problematic usages of `ReactDOM.createRoot()` ([@trueadm](https://github.com/trueadm) in [#17937](https://github.com/facebook/react/pull/17937))
202+
- Remove `ReactDOM.createRoot()` callback params and added warnings on usage ([@bvaughn](https://github.com/bvaughn) in [#17916](https://github.com/facebook/react/pull/17916))
203+
- Don't group Idle/Offscreen work with other work ([@sebmarkbage](https://github.com/sebmarkbage) in [#17456](https://github.com/facebook/react/pull/17456))
204+
- Adjust `SuspenseList` CPU bound heuristic ([@sebmarkbage](https://github.com/sebmarkbage) in [#17455](https://github.com/facebook/react/pull/17455))
205+
- Add missing event plugin priorities ([@trueadm](https://github.com/trueadm) in [#17914](https://github.com/facebook/react/pull/17914))
206+
- Fix `isPending` only being true when transitioning from inside an input event ([@acdlite](https://github.com/acdlite) in [#17382](https://github.com/facebook/react/pull/17382))
207+
- Fix `React.memo` components dropping updates when interrupted by a higher priority update ([@acdlite](<(https://github.com/acdlite)>) in [#18091](https://github.com/facebook/react/pull/18091))
208+
- Don't warn when suspending at the wrong priority ([@gaearon](https://github.com/gaearon) in [#17971](https://github.com/facebook/react/pull/17971))
209+
- Fix a bug with rebasing updates ([@acdlite](https://github.com/acdlite) and [@sebmarkbage](https://github.com/sebmarkbage) in [#17560](https://github.com/facebook/react/pull/17560), [#17510](https://github.com/facebook/react/pull/17510), [#17483](https://github.com/facebook/react/pull/17483), [#17480](https://github.com/facebook/react/pull/17480))

content/community/conferences.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ February 27 & 28, 2020 in Sydney, Australia
2525
### ReactConf Japan 2020 {#reactconfjp-2020}
2626
March 21, 2020 in Tokyo, Japan
2727

28-
[Website](https://reactconf.jp/) - [Twitter](https://twitter.com/reactjapanconf)
28+
[Website](https://reactconf.jp/) - [Twitter](https://twitter.com/reactjp)
2929

3030
### Reactathon 2020 {#reactathon-2020}
3131
March 30 - 31, 2020 in San Francisco, CA

content/community/meetups.md

+3
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ Do you have a local React.js meetup? Add it here! (Please keep the list alphabet
144144
## Switzerland {#switzerland}
145145
* [Zurich](https://www.meetup.com/Zurich-ReactJS-Meetup/)
146146

147+
## Turkey {#turkey}
148+
* [Istanbul](https://www.meetup.com/ReactJS-Istanbul/)
149+
147150
## Ukraine {#ukraine}
148151
* [Kyiv](https://www.meetup.com/Kyiv-ReactJS-Meetup)
149152

content/docs/accessibility.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ class BlurExample extends React.Component {
371371
각각의 위젯 타입은 명확한 디자인 패턴이 있으며, 사용자와 사용자 에이전트 모두 특정 방향으로 기능하는 것이 요구됩니다.
372372

373373
- [WAI-ARIA Authoring Practices - 디자인 패턴과 위젯](https://www.w3.org/TR/wai-aria-practices/#aria_ex)
374-
- [Heydon Pickering - ARIA 예시](https://heydonworks.com/practical_aria_examples/)
374+
- [Heydon Pickering - ARIA 예시](https://heydonworks.com/article/practical-aria-examples/)
375375
- [포괄적 컴포넌트](https://inclusive-components.design/)
376376

377377
## 기타 고려사항 {#other-points-for-consideration}

content/docs/concurrent-mode-patterns.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ function ProfileTrivia({ resource }) {
507507

508508
**[Try it on CodeSandbox](https://codesandbox.io/s/focused-mountain-uhkzg)**
509509

510-
If you press "Open Profile" now, you can tell something is wrong. It takes whole seven seconds to make the transition now! This is because our trivia API is too slow. Let's say we can't make the API faster. How can we improve the user experience with this constraint?
510+
If you press "Open Profile" now, you can tell something is wrong. It takes a whole seven seconds to make the transition now! This is because our trivia API is too slow. Let's say we can't make the API faster. How can we improve the user experience with this constraint?
511511

512512
If we don't want to stay in the Pending state for too long, our first instinct might be to set `timeoutMs` in `useTransition` to something smaller, like `3000`. You can try this [here](https://codesandbox.io/s/practical-kowalevski-kpjg4). This lets us escape the prolonged Pending state, but we still don't have anything useful to show!
513513

content/docs/error-boundaries.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class MyComponent extends React.Component {
152152
if (this.state.error) {
153153
return <h1>Caught an error.</h1>
154154
}
155-
return <div onClick={this.handleClick}>Click Me</div>
155+
return <button onClick={this.handleClick}>Click Me</button>
156156
}
157157
}
158158
```

content/docs/nav.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@
100100
title: 합성 이벤트
101101
- id: test-utils
102102
title: 테스트 유틸리티
103-
- id: shallow-renderer
104-
title: 얕은 렌더러
105103
- id: test-renderer
106104
title: 테스트 렌더러
107105
- id: javascript-environment-requirements
@@ -141,7 +139,7 @@
141139
- id: concurrent-mode-intro
142140
title: Concurrent 모드 소개
143141
- id: concurrent-mode-suspense
144-
title: 데이터를 가져오기 위한 Suspense
142+
title: 데이터를 가져오기 위한 Suspense
145143
- id: concurrent-mode-patterns
146144
title: Concurrent UI 패턴
147145
- id: concurrent-mode-adoption

content/docs/reconciliation.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ React는 `<li>Duke</li>`와 `<li>Villanova</li>` 종속 트리를 그대로 유
142142

143143
인덱스를 key로 사용 중 배열이 재배열되면 컴포넌트의 state와 관련된 문제가 발생할 수 있습니다. 컴포넌트 인스턴스는 key를 기반으로 갱신되고 재사용됩니다. 인덱스를 key로 사용하면, 항목의 순서가 바뀌었을 때 key 또한 바뀔 것입니다. 그 결과로, 컴포넌트의 state가 엉망이 되거나 의도하지 않은 방식으로 바뀔 수도 있습니다.
144144

145-
인덱스를 key로 사용하여 문제가 발생하는 Codepen 예시는 [여기](codepen://reconciliation/index-used-as-key)에 있습니다. 그리고 개선한 예시에서는 인덱스를 key로 사용하지 않으면서도 앞에서 다뤘던 재배열, 정렬 그리고 이어서 발생하는 문제들을 어떻게 해결하는지 [여기](codepen://reconciliation/no-index-used-as-key)에서 확인할 수 있습니다
145+
[인덱스를 key로 사용하여 문제가 발생하는 Codepen 예시는 여기에 있습니다.](codepen://reconciliation/index-used-as-key) 그리고 [개선한 예시에서는 인덱스를 key로 사용하지 않으면서도 앞에서 다뤘던 재배열, 정렬 그리고 이어서 발생하는 문제들을 어떻게 해결하는지 여기에서 확인할 수 있습니다.](codepen://reconciliation/no-index-used-as-key)
146146

147147
## 고려 사항 {#tradeoffs}
148148

content/docs/rendering-elements.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const element = <h1>Hello, world</h1>;
2020

2121
>**주의**
2222
>
23-
>더 널리 알려진 개념인 "컴포넌트"와 엘리먼트를 혼동할 수 있습니다. [다음 장](/docs/components-and-props.html)에서 컴포넌트에 대해 소개할 예정입니다. 엘리먼트는 컴포넌트의 "구성 요소"이므로 이번 장을 읽고 나서 다음 장으로 넘어갈 것을 권합니다.
23+
>더 널리 알려진 개념인 "컴포넌트"와 엘리먼트를 혼동할 수 있습니다. [다음 장](/docs/components-and-props.html)에서 컴포넌트에 대해 소개할 예정입니다. 엘리먼트는 컴포넌트의 "구성 요소"이므로 이번 장을 읽고 나서 다음 장으로 넘어갈 것을 권합니다.
2424
2525
## DOM에 엘리먼트 렌더링하기 {#rendering-an-element-into-the-dom}
2626

0 commit comments

Comments
 (0)