|
1 | 1 | ---
|
2 |
| -title: "React v16.7: No, This Is Not the One With Hooks" |
| 2 | +title: "React v16.7:不包含 Hook 的版本" |
3 | 3 | author: [acdlite]
|
4 | 4 | ---
|
5 | 5 |
|
6 |
| -Our latest release includes an important performance bugfix for `React.lazy`. Although there are no API changes, we're releasing it as a minor instead of a patch. |
| 6 | +我们最新的发布版本包括了一个关于 `React.lazy` 的重要性能问题修复。尽管发布里不包括 API 的更改,我们还是以次要版本而不是修订版本的形式发布了。 |
7 | 7 |
|
8 |
| -## Why Is This Bugfix a Minor Instead of a Patch? {#why-is-this-bugfix-a-minor-instead-of-a-patch} |
| 8 | +## 这个问题修复为什么是次要版本而不是修订版本? {#why-is-this-bugfix-a-minor-instead-of-a-patch} |
9 | 9 |
|
10 |
| -React follows [semantic versioning](/docs/faq-versioning.html). Typically, this means that we use patch versions for bugfixes, and minors for new (non-breaking) features. However, we reserve the option to release minor versions even if they do not include new features. The motivation is to reserve patches for changes that have a very low chance of breaking. Patches are the most important type of release because they sometimes contain critical bugfixes. That means patch releases have a higher bar for reliability. It's unacceptable for a patch to introduce additional bugs, because if people come to distrust patches, it compromises our ability to fix critical bugs when they arise — for example, to fix a security vulnerability. |
| 10 | +React 遵循 [语义化版本](/docs/faq-versioning.html)的原则。一般来说这意味着问题修复会发布成修订版,而新功能(不兼容的改动)会发布成次要版本。不过即使没有新功能,我们仍保留发布次要版的权力。这么做的目的是要确保修订版里的更动有着最小的破坏性影响。修订版是发布版本里最重要的一个版本,因为它时常包括了紧急问题的修复。所以修订版对可靠性的要求更高。而修订版带来更多的问题是不能被接受的。因为当大家开始不信任修订版时,我们即时解决紧急问题的能力也被影响了 — 比如说解决安全漏洞。 |
11 | 11 |
|
12 |
| -We never intend to ship bugs. React has a hard-earned reputation for stability, and we intend to keep it that way. We thoroughly test every version of React before releasing. This includes unit tests, generative (fuzzy) tests, integration tests, and internal dogfooding across tens of thousands of components. However, sometimes we make mistakes. That's why, going forward, our policy will be that if a release contains non-trivial changes, we will bump the minor version, even if the external behavior is the same. We'll also bump the minor when changing `unstable_`-prefixed APIs. |
| 12 | +我们从不会蓄意提交有问题的发布。React 稳定的声誉来之不易,我们也打算继续维持。在发布前我们都会仔细测试每个新的版本。这包括了单元测试, 生成 (fuzzy) 测试, 集成测试, 以及内部 dogfooding 几万个组件。但是,我们也是会出错的。这就是为什么从现在开始,我们的政策就是如果新的发布包含了非无足轻重的改动,我们将递增次版本号, 即使外在行为不变。当更改有 `unstable_` 前缀的 API 过后我们也会递增次版本号。 |
13 | 13 |
|
14 |
| -## Can I Use Hooks Yet? {#can-i-use-hooks-yet} |
| 14 | +## 我可以使用 Hook 了吗? {#can-i-use-hooks-yet} |
15 | 15 |
|
16 |
| -Not yet, but soon! |
| 16 | +暂时还不行, 不过很快了! |
17 | 17 |
|
18 |
| -At React Conf, we said that 16.7 would be the first release to include Hooks. This was a mistake. We shouldn't have attached a specific version number to an unreleased feature. We'll avoid this in the future. |
| 18 | +在 React Conf 上, 我们宣布了 16.7 的发行将包括 Hook。这是个失误。我们不应该把还没有发行的功能连上具体的版本号。我们以后会避免犯同样的错误。 |
19 | 19 |
|
20 |
| -Although 16.7 does not include Hooks, please do not infer anything about the timeline of the Hooks launch. Our plans for Hooks are unchanged: |
| 20 | +尽管 16.7 还不包括 Hook, 请不要胡乱揣测 Hook 的发布时间表。发布 Hook 的计划不变: |
21 | 21 |
|
22 |
| -- The [Hooks proposal](https://github.com/reactjs/rfcs/pull/68) was accepted ([with minor planned changes in response to feedback](https://github.com/reactjs/rfcs/pull/68#issuecomment-439314884)). |
23 |
| -- The [implementation](https://github.com/facebook/react/commit/7bee9fbdd49aa5b9365a94b0ddf6db04bc1bf51c) was merged into the React repo (behind a feature flag). |
24 |
| -- We're currently in the testing phase, and you can expect a public release within a few months. |
| 22 | +- [Hook 提案](https://github.com/reactjs/rfcs/pull/68)被接受了([附加了根据反馈讯息的次要改动](https://github.com/reactjs/rfcs/pull/68#issuecomment-439314884)). |
| 23 | +- [执行](https://github.com/facebook/react/commit/7bee9fbdd49aa5b9365a94b0ddf6db04bc1bf51c) 被合并进了 React repo (隐藏在功能切换后)。 |
| 24 | +- 我们现在正在测试阶段,敬请期待几个月后的发布。 |
25 | 25 |
|
26 |
| -We've heard from many people who want to start using Hooks in their apps. We also can't wait to ship them! But because Hooks changes how we write React components, we are taking extra time to get the details right. We appreciate your patience as we prepare this exciting new feature for widespread, ahem, *use*. |
| 26 | +我们听到了很多人想要开始在应用里使用 Hook。我们也迫不及待的想要发表!但是因为 Hook 会改变大家写组件的方式,我们决定多花些时间处理细节。对大家耐心等待这个激动人心的新功能的推广运用,我们深表感激。 |
27 | 27 |
|
28 |
| -Learn more about [our roadmap](/blog/2018/11/27/react-16-roadmap.html) in our previous post. |
| 28 | +想了解更多 [我们的规划](/blog/2018/11/27/react-16-roadmap.html) 参考上篇博文。 |
29 | 29 |
|
| 30 | +## 安装 {#installation} |
30 | 31 |
|
31 |
| -## Installation {#installation} |
| 32 | +React v16.7.0 已经在 npm 上发布。 |
32 | 33 |
|
33 |
| -React v16.7.0 is available on the npm registry. |
34 |
| - |
35 |
| -To install React 16 with Yarn, run: |
| 34 | +使用 Yarn 来安装 React 16,执行: |
36 | 35 |
|
37 | 36 | ```bash
|
38 | 37 | yarn add react@^16.7.0 react-dom@^16.7.0
|
39 | 38 | ```
|
40 | 39 |
|
41 |
| -To install React 16 with npm, run: |
| 40 | +使用 npm 来安装 React 16,执行: |
42 | 41 |
|
43 | 42 | ```bash
|
44 | 43 | npm install --save react@^16.7.0 react-dom@^16.7.0
|
45 | 44 | ```
|
46 | 45 |
|
47 |
| -We also provide UMD builds of React via a CDN: |
| 46 | +我们同时通过 CDN 的链接提供 UMD 打包的 React: |
48 | 47 |
|
49 | 48 | ```html
|
50 | 49 | <script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
|
51 | 50 | <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
|
52 | 51 | ```
|
53 | 52 |
|
54 |
| -Refer to the documentation for [detailed installation instructions](/docs/installation.html). |
| 53 | +请参考文档的[详细安装指南](/docs/installation.html). |
55 | 54 |
|
56 |
| -## Changelog {#changelog} |
| 55 | +## 更新日志 {#changelog} |
57 | 56 |
|
58 | 57 | ### React DOM {#react-dom}
|
59 | 58 |
|
60 |
| -* Fix performance of `React.lazy` for large numbers of lazily-loaded components. ([@acdlite](http://github.com/acdlite) in [#14429](https://github.com/facebook/react/pull/14429)) |
61 |
| -* Clear fields on unmount to avoid memory leaks. ([@trueadm](http://github.com/trueadm) in [#14276](https://github.com/facebook/react/pull/14276)) |
62 |
| -* Fix bug with SSR and context when mixing `react-dom/[email protected]` and `react@<16.6`. ( [@gaearon](http://github.com/gaearon) in [#14291](https://github.com/facebook/react/pull/14291)) |
63 |
| -* Fix a performance regression in profiling mode. ([@bvaughn](http://github.com/bvaughn) in [#14383](https://github.com/facebook/react/pull/14383)) |
| 59 | +* 修复当有大数量 lazily-loaded 组件时, `React.lazy` 的性能问题。([@acdlite](http://github.com/acdlite) 在 [#14429](https://github.com/facebook/react/pull/14429)) |
| 60 | +* 清除 unmount 时的 fields 来防止内存泄漏。([@trueadm](http://github.com/trueadm) 在 [#14276](https://github.com/facebook/react/pull/14276)) |
| 61 | +* 修复当共用 `react-dom/[email protected]` 和 `react@<16.6` 时 SSR 和 context 的问题。 ( [@gaearon](http://github.com/gaearon) 在 [#14291](https://github.com/facebook/react/pull/14291)) |
| 62 | +* 修复一个 profiling mode 的性能回退。 ([@bvaughn](http://github.com/bvaughn) 在 [#14383](https://github.com/facebook/react/pull/14383)) |
64 | 63 |
|
65 |
| -### Scheduler (Experimental) {#scheduler-experimental} |
| 64 | +### 调度器 (试验阶段) {#scheduler-experimental} |
66 | 65 |
|
67 |
| -* Post to MessageChannel instead of window. ([@acdlite](http://github.com/acdlite) in [#14234](https://github.com/facebook/react/pull/14234)) |
68 |
| -* Reduce serialization overhead. ([@developit](http://github.com/developit) in [#14249](https://github.com/facebook/react/pull/14249)) |
69 |
| -* Fix fallback to `setTimeout` in testing environments. ([@bvaughn](http://github.com/bvaughn) in [#14358](https://github.com/facebook/react/pull/14358)) |
70 |
| -* Add methods for debugging. ([@mrkev](http://github.com/mrkev) in [#14053](https://github.com/facebook/react/pull/14053)) |
| 66 | +* 提交到 MessageChannel 来代替 window。([@acdlite](http://github.com/acdlite) 提交在 [#14234](https://github.com/facebook/react/pull/14234)) |
| 67 | +* 减少序列化的成本。([@developit](http://github.com/developit) 提交在 [#14249](https://github.com/facebook/react/pull/14249)) |
| 68 | +* 修复测试环境里 `setTimeout` 的降级。([@bvaughn](http://github.com/bvaughn) 提交在 [#14358](https://github.com/facebook/react/pull/14358)) |
| 69 | +* 添加调试方法。([@mrkev](http://github.com/mrkev) 提交在 [#14053](https://github.com/facebook/react/pull/14053)) |
0 commit comments