React 18 的计划

2021年6月8日,由 Andrew ClarkBrian VaughnChristine AbernathyDan AbramovRachel NaborsRick HanlonSebastian MarkbågeSeth Webster 撰写

🌐 June 8, 2021 by Andrew Clark, Brian Vaughn, Christine Abernathy, Dan Abramov, Rachel Nabors, Rick Hanlon, Sebastian Markbåge, and Seth Webster


React 团队很高兴分享一些更新:

🌐 The React team is excited to share a few updates:

  1. 我们已经开始着手 React 18 的发布工作,这将是我们的下一个主要版本。
  2. 我们已成立一个工作组,为社区准备逐步采用 React 18 中的新功能。
  3. 我们已经发布了 React 18 Alpha,以便库作者可以尝试并提供反馈。

这些更新主要面向第三方库的维护者。如果你正在学习、教学或使用 React 构建面向用户的应用,你可以放心忽略这篇文章。但如果你感到好奇,欢迎关注 React 18 工作组的讨论!

🌐 These updates are primarily aimed at maintainers of third-party libraries. If you’re learning, teaching, or using React to build user-facing applications, you can safely ignore this post. But you are welcome to follow the discussions in the React 18 Working Group if you’re curious!


React 18 中的新特性

🌐 What’s coming in React 18

当发布时,React 18 将包含开箱即用的改进(例如 自动批处理)、新的 API(例如 startTransition)以及一个带有内置 React.lazy 支持的 新流式服务器渲染器

🌐 When it’s released, React 18 will include out-of-the-box improvements (like automatic batching), new APIs (like startTransition), and a new streaming server renderer with built-in support for React.lazy.

这些功能之所以可能,是因为我们在 React 18 中添加了一种新的可选择机制。它被称为“并发渲染”,可以让 React 同时准备多个 UI 版本。这个变化大多发生在幕后,但它为提升应用的实际和感知性能开辟了新的可能性。

🌐 These features are possible thanks to a new opt-in mechanism we’re adding in React 18. It’s called “concurrent rendering” and it lets React prepare multiple versions of the UI at the same time. This change is mostly behind-the-scenes, but it unlocks new possibilities to improve both real and perceived performance of your app.

如果你一直在关注我们对 React 未来的研究(我们并不指望你会!),你可能听说过“并发模式”或它可能会破坏你的应用。针对社区的这些反馈,我们重新设计了渐进式采用的升级策略。并非全有或全无的“模式”,并发渲染只会对由新功能触发的更新启用。实际上,这意味着你将能够在不重写的情况下采用 React 18,并以自己的节奏尝试新功能。

🌐 If you’ve been following our research into the future of React (we don’t expect you to!), you might have heard of something called “concurrent mode” or that it might break your app. In response to this feedback from the community, we’ve redesigned the upgrade strategy for gradual adoption. Instead of an all-or-nothing “mode”, concurrent rendering will only be enabled for updates triggered by one of the new features. In practice, this means you will be able to adopt React 18 without rewrites and try the new features at your own pace.

渐进式采用策略

🌐 A gradual adoption strategy

由于 React 18 的并发是可选的,因此组件行为没有显著的现成破坏性更改。你可以以最小甚至无需修改应用代码的方式升级到 React 18,所需的努力与典型的重大 React 版本相当。根据我们将几个应用转换为 React 18 的经验,我们预计许多用户可以在一个下午内完成升级。

🌐 Since concurrency in React 18 is opt-in, there are no significant out-of-the-box breaking changes to component behavior. You can upgrade to React 18 with minimal or no changes to your application code, with a level of effort comparable to a typical major React release. Based on our experience converting several apps to React 18, we expect that many users will be able to upgrade within a single afternoon.

我们成功地将并发特性发布到了 Facebook 的数万个组件上,根据我们的经验,我们发现大多数 React 组件“无需额外修改”就能正常运行。我们致力于确保整个社区的升级过程顺利,因此今天我们宣布成立 React 18 工作组。

🌐 We successfully shipped concurrent features to tens of thousands of components at Facebook, and in our experience, we’ve found that most React components “just work” without additional changes. We’re committed to making sure this is a smooth upgrade for the entire community, so today we’re announcing the React 18 Working Group.

与社区合作

🌐 Working with the community

我们正在为此次发布尝试一些新做法:我们邀请了来自整个 React 社区的专家、开发者、库作者和教育工作者参与我们的 React 18 工作小组,以提供反馈、提出问题并协作推进发布。我们无法邀请所有想邀请的人加入这个初始的小组,但如果这个尝试成功,我们希望未来会有更多机会!

🌐 We’re trying something new for this release: We’ve invited a panel of experts, developers, library authors, and educators from across the React community to participate in our React 18 Working Group to provide feedback, ask questions, and collaborate on the release. We couldn’t invite everyone we wanted to this initial, small group, but if this experiment works out, we hope there will be more in the future!

React 18 工作组的目标是为现有应用和库顺利、渐进地采用 React 18 做好生态系统准备。 工作组托管在 GitHub Discussions 上,公众可以阅读。工作组成员可以留下反馈、提问和分享想法。核心团队还将使用讨论仓库分享我们的研究成果。随着正式版本发布的临近,任何重要信息也会发布在此博客上。

有关升级到 React 18 的更多信息,或关于该版本发布的其他资源,请参阅 React 18 公告文章

🌐 For more information on upgrading to React 18, or additional resources about the release, see the React 18 announcement post.

访问 React 18 工作组

🌐 Accessing the React 18 Working Group

每个人都可以阅读 React 18 工作组仓库 中的讨论。

🌐 Everyone can read the discussions in the React 18 Working Group repo.

由于我们预计工作组会在初期引起极大的兴趣,只有受邀成员才能创建或评论话题。然而,这些话题对公众完全可见,因此每个人都能访问相同的信息。我们认为这是在为工作组成员创建高效环境与对更广泛社区保持透明之间的一个良好折衷方案。

🌐 Because we expect an initial surge of interest in the Working Group, only invited members will be allowed to create or comment on threads. However, the threads are fully visible to the public, so everyone has access to the same information. We believe this is a good compromise between creating a productive environment for working group members, while maintaining transparency with the wider community.

一如既往,你可以将错误报告、问题和一般反馈提交到我们的问题跟踪器

🌐 As always, you can submit bug reports, questions, and general feedback to our issue tracker.

如何在今天试用 React 18 Alpha

🌐 How to try React 18 Alpha today

新的 alpha 版本会定期使用 @alpha 标签发布到 npm。这些版本是基于我们主仓库的最新提交构建的。当一个功能或错误修复被合并后,它将在下一个工作日的 alpha 版本中出现。

🌐 New alphas are regularly published to npm using the @alpha tag. These releases are built using the most recent commit to our main repo. When a feature or bugfix is merged, it will appear in an alpha the following weekday.

在 alpha 版本之间可能会有显著的行为或 API 变化。请记住,不建议在面向用户的生产应用中使用 alpha 版本

🌐 There may be significant behavioral or API changes between alpha releases. Please remember that alpha releases are not recommended for user-facing, production applications.

React 18 预计发布时间表

🌐 Projected React 18 release timeline

我们没有具体的发布日期安排,但我们预计在 React 18 准备好用于大多数生产应用之前,需要几个月的反馈和迭代。

🌐 We don’t have a specific release date scheduled, but we expect it will take several months of feedback and iteration before React 18 is ready for most production applications.

  • 阿尔法库:今天可用
  • 公开测试版:至少几个月
  • 候选发布版 (RC):至少在测试版之后几周
  • 一般可用性:在 RC 后至少几周

有关我们预计发布计划的更多细节,请参见工作组。当我们接近公开发布时,我们将在此博客上发布更新。

🌐 More details about our projected release timeline are available in the Working Group. We’ll post updates on this blog when we’re closer to a public release.