React 19 Is Here - Are You Ready?

Theo - t3․gg
16 Feb 202420:11

Summary

TLDRReactチームのアップデートについて解説。React Compilerが新機能として導入され、将来的には手動でのコンポーネントのメモ化が不要になる可能性がある。また、React Labsのブログで取り上げられたアクションとオプティミスティックステートの改善、そしてReact Canaryの紹介。React 19のメジャーアップデートも予告され、Web Componentsのサポートや非表示のオブジェクトの活性化管理など、新たな機能が追加される。

Takeaways

  • 📣 Reactの将来の変更について話し合い、重要なアップデートが予定されていることが明らかになった。
  • 🚀 React Compilerは研究プロジェクトではなくなり、Reactの再描画を最適化することを目指している。
  • 🎯 手動でのメモ化は合理的な妥協であるが、ReactチームはUIの正確な部分だけを自動的に再描画することを目指している。
  • 🔍 ReactのコンパイラはJavaScriptのルールとReactのルールをモデル化してコードを安全にコンパイルすることができる。
  • 📈 Reactは downwards compatibleを重視しており、過去のコードが新しいバージョンでも動作することを保証している。
  • 🔧 ReactのStrict ModeとESLintプラグインを使用することで、コードの品質を向上させ、将来の機能に備えることができる。
  • 🌟 Actionsと呼ばれる新機能が導入され、クライアントからサーバーへのデータ送信を容易にすることができる。
  • 🔄 UseOptimisticと呼ばれる新しい機能が導入され、最適な状態の更新を管理することができる。
  • 📚 React Canaryという新しい機能が導入され、開発者は安定版リリース前に新しい機能を試することができる。
  • 💻 Document MetadataとAsset Loadingの機能が強化され、Reactがタイトル、メタタグ、 Stylesheets、Fontsなどのレンダリングをサポートする。
  • 🔧 React 19が次のメジャーバージョンとして準備されており、Web Componentsのサポートや破壊的な変更が含まれる予定である。

Q & A

  • Reactチームが今後も継続してサポートする機能は何ですか?

    -Reactチームは、既存の機能を継続してサポートする予定であり、将来的に不要になる可能性があるものの、現在は引き続き使用することができます。

  • Reactのコンパイラに関してどのような変更が行われていますか?

    -Reactコンパイラは研究プロジェクトではなくなり、より多くのコードを安全にコンパイルすることが可能となり、パフォーマンス向上が期待されています。

  • ReactのコンパイラがどのようにJavaScriptを最適化するのでしょうか?

    -Reactコンパイラは、JavaScriptのルールとReactのルールをモデル化してコードを安全にコンパイルすることができます。

  • Reactのコンパイラが正しいルールを追うコードを検出できない場合、どのように対応するのでしょうか?

    -コンパイラは安全ではない場合、コンパイルをスキップすることがあります。

  • Reactチームが今後もバックwards compatibilityを重視していることをどのように示しているのですか?

    -Reactチームは、過去のバージョンのコードが新しい環境でも動作することを重視しており、将来のアップグレードを容易にしています。

  • React Canaryとは何ですか?

    -React Canaryは、安定版リリース前に個別の新機能を採用するためのオプションであり、コミュニティによるフィードバックを活用して機能を最終化します。

  • React 19の主な新機能は何ですか?

    -React 19では、アセットローディング、ドキュメントメタデータ、アクションなど、複数の新機能が含まれます。また、Web Componentsのサポートも予定されています。

  • アクション機能が導入されることで、どのような利点がありますか?

    -アクション機能を使うことで、クライアントからサーバーへのデータ送信を管理し、標準的なJavaScriptまたはサーバーディレクティブを使用して定義できます。

  • useOptimisticと呼ばれる新しい機能は何ですか?

    -useOptimisticは、アクションを使用した最適な状態の更新を管理するための機能であり、最終状態を仮に更新して、サーバーからデータを受け取った後で自動的に元に戻すことができます。

  • Reactチームが今後もコミュニティへのフィードバックを重視していることをどのように示していますか?

    -Reactチームは、React Canaryを使用してコミュニティによるフィードバックを活用し、機能を最終化しています。また、今後もコミュニティの意見を取り入れる予定を発表しています。

  • offscreenからactivityへと名前が変更された理由は何ですか?

    -offscreenは非表示部分に適用されることを示唆する名称であり、しかし実際には表示されているがアクティブではない部分(例えばモーダルの背後にあるコンテンツ)も対象とすることができました。

Outlines

00:00

📢 Reactの主要な変更点についての解説

このパラグラフでは、Reactの核心チームが大規模な更新について発表したことに焦点を当てています。具体的には、useMemo、useCallback、memo、forwardRef、React.lazy、useContext、throw promise、およびcontext providersなどのフックスとAPIが将来的には不要になる可能性があるという話題です。これらの変更にも関わらず、既存の機能が非推奨になることはなく、新しいReactのバージョンでも従来のコードは引き続き機能するでしょう。主な変更点は、パフォーマンスの向上と開発者の利便性の向上に焦点を当てたもので、Reactコンパイラの導入が特に注目されています。これにより、開発者は手動でのメモ化を行わずに、Reactが適切なUI部分のみを再レンダリングするように自動最適化されます。また、ESLintルールの導入が開発者がより最適化されたコードを書くのを助けると期待されています。

05:01

🔄 Hooksとサーバーコンポーネントの相互運用性

このパラグラフでは、HooksがどのようにしてReactのバージョン間での互換性を保ちながら発展してきたかについて説明しています。特に、古いコードが新しいバージョンのReactで問題なく動作すること、および古いコンポーネントを新しいHooksベースのコンポーネント内で使用できることが強調されています。さらに、Reactコンパイラの厳格なサポートが既存の相互運用性を損なうことなくどのように組み込まれているかについても触れられています。また、ESLintとstrictモードを活用することで、開発者がReactのルールに従ってより堅牢なアプリケーションを構築できるようになることが説明されています。

10:02

🆕 新しいReact Canaryの機能とサーバーコンポーネント

このパラグラフでは、React Canaryの導入とその利点に焦点を当てています。Canaryバージョンは、コミュニティのフィードバックを得ながら公開的に機能を開発し、最終的な機能を完成させる新しい開発手法です。特に、サーバーコンポーネント、アセットローディング、ドキュメントメタデータ、およびアクションの導入が注目されています。これらの機能は、クライアントとサーバー間のデータ送信の管理、リソースの事前ロード、およびアプリケーションのメタデータ管理を簡素化します。また、Reactが全ての環境で一貫したプログラミングモデルを提供することの重要性についても触れています。

15:04

🚀 React 19の概要と将来のアップデート

このパラグラフでは、React 19への移行と、それに含まれる新機能について説明しています。特に、Reactのメジャーバージョンアップに伴うウェブコンポーネントのサポート追加や、アセットローディングとドキュメントメタデータの統合など、いくつかの機能が破壊的変更として扱われることが強調されています。また、新しい開発フィロソフィーとして、React Canaryを通じてコミュニティと共に機能を開発し、フィードバックを得ることの重要性にも触れられています。

20:04

👋 ビデオの締めくくりと視聴者へのメッセージ

最終パラグラフでは、視聴者に向けての簡潔なメッセージが述べられています。Reactに関する大きな更新と変更点についての詳細な説明を終えた後、視聴者にコメントでの意見や質問を求め、次回の更新までの別れの挨拶をしています。この部分は、視聴者との対話を促進し、コミュニティの一員としての参加を奨励することを目的としています。

Mindmap

Keywords

💡React

Reactは、Facebookが開発したJavaScriptライブラリで、ウェブアプリケーションの開発に利用されます。この動画では、Reactの新しい機能や改良点について説明されています。

💡React Compiler

React Compilerは、Reactアプリケーションのパフォーマンスを向上させるために開発されているコンパイラです。JavaScriptの動的な性質を考慮に入れた最適化を行って、再描画を減らすことでパフォーマンスを向上させます。

💡Hooks

Hooksは、React 16.8で導入された機能で、クラスコンポーネントの概念を使わずに、状態や副作用を扱うことができます。この動画では、新しいHooksの紹介や、既存のHooksの使用が変更される可能性について触れられています。

💡Server Components

Server Componentsは、Reactの機能で、サーバー側でのみ実行されるコンポーネントを作成することができます。これにより、サーバーとクライアントの負荷を適切に分担し、パフォーマンスを向上させることができます。

💡Actions

Actionsは、Reactの新しい機能で、クライアントからサーバーへのデータ送信を管理するために使用されます。フォームの送信やデータベースの変更を実行するために使用できます。

💡Offscreen

Offscreenは、Reactの開発中機能であり、画面に表示されていないコンポーネントの更新を背景で行うことができます。これにより、コンポーネントが再表示されるときに即座に利用できるようにすることができます。

💡Suspense

Suspenseは、React 16で導入された機能で、データの取得やコンポーネントの読み込み中にローディング状態を表示することができます。これにより、ユーザー体験を向上させることができます。

💡Document Metadata

Document Metadataは、Reactの新機能で、コンポーネントツリーの任意の場所で、titleやmetaタグをレンダリングすることができます。これにより、SEOやメタデータ管理を効率化できます。

💡Asset Loading

Asset Loadingは、Reactの新機能で、スタイルシートやフォント、スクリプトなどのリソースの読み込みライフサイクルを管理することができます。これにより、リソースの読み込みタイミングをコントロールし、パフォーマンスを向上させることができます。

💡React 19

React 19は、Reactの次のメジャーバージョンで、新しい機能や改良点を含んでいます。このバージョンでは、Web ComponentsのサポートやBreaking Changeが含まれています。

💡Activity

Activityは、Reactの開発中機能で、アプリケーションの特定の部分をアクティブまたはインアクティブに制御することができます。これにより、背景での処理を続けたり、モーダルの背後に表示されているコンテンツを制御することができます。

Highlights

Manual memoization in React is being replaced by an optimized compiler for better performance and automatic rendering.

React compiler is designed to work safely by modeling JavaScript and React rules, aiming to automatically render only the right parts of the UI when state changes.

React's historical backwards compatibility is emphasized, with the new features aiming to maintain this for ease of adoption and transition.

Lint rules are introduced as a way to make code more optimizable by adhering to React's rules, with tools like strict mode and React's ESLint plugin recommended for developers.

The React team is working on consolidated documentation of React's rules and updates to the ESLint plugin for better development experience.

Actions are introduced as a feature for sending data from the client to the server, with built-in lifecycle management and hooks for form status and state.

UseOptimistic hook is introduced for managing optimistic state updates, allowing temporary changes that revert once the final state commits.

Server components and asset loading have landed in React Canary, with documentation and support for production use.

React 19 will be a major release, including long-requested improvements like support for web components and breaking changes.

The React team is focusing on finalizing the Activity feature (formerly known as Offscreen), which allows parts of the app to be active or inactive without blocking the main thread.

React canaries are introduced for community involvement in the development process, allowing for feedback and experimentation with new features before stable release.

The React team emphasizes the importance of not just React APIs, but the mental model and composability that makes React approachable for developers.

The React compiler has been successfully implemented across all of instagram.com, showcasing its potential for real-world application at scale.

The React philosophy of providing a single set of APIs that work across all platforms and environments is highlighted, aiming for consistency and ease of future upgrades.

The React team is working on improving the developer experience with better tooling and IDE support, making the development process more efficient and enjoyable.

The React team's commitment to open-sourcing the compiler and expanding the team to accelerate its rollout is mentioned, showing a dedication to community and collaboration.

The update emphasizes the importance of community involvement in the React development process, highlighting the impact of feedback on the evolution of features like server components.

Transcripts

play00:00

before you get mad at me for the

play00:00

thumbnail this is what Andrew Clark from

play00:02

the react core team actually tweeted it

play00:04

might not be quite as extreme but this

play00:06

is some big news and I think we need to

play00:08

talk about it because throwing away use

play00:10

memo use call back memo forward ref

play00:12

react. lazy use context throw promise

play00:15

and context providers there's a lot

play00:17

changing right now so what the heck's

play00:19

going on why is all of this going to

play00:21

change well first and foremost it's

play00:22

important to know none of this has to

play00:24

change you can continue using things the

play00:26

way you currently use them and even in

play00:27

new react versions you're going to be

play00:28

fine I don't think they any intention to

play00:30

deprecate the existing functionality at

play00:32

any point you just won't necessarily

play00:34

need the things on the left side here in

play00:36

the future some of them are just

play00:38

semantic changes like context. provider

play00:40

becoming just context because you no

play00:41

longer need to use context you can just

play00:44

call use with the context there's also

play00:46

has some performance benefits we'll talk

play00:47

about in a bit but we need to read the

play00:50

official update from the react core team

play00:52

react Labs what we've been working on

play00:54

February

play00:55

2024 these blog posts are great and they

play00:57

haven't been doing them quite as often

play00:59

as I would have hoped like the last one

play01:00

was was that a year ago yeah March 2023

play01:02

was the last one so it's been almost a

play01:04

year since the last of these updates

play01:05

very thankful they're still happening

play01:07

and also Dan still helping out the first

play01:08

update is react compiler react compiler

play01:10

is no longer a research project yeah we

play01:12

mentioned that before in the Tweet as

play01:13

discussed in their previous post about

play01:15

it react can sometimes rerender too much

play01:18

when State changes since the early days

play01:19

of react our solution for such cases has

play01:21

been manual memoization and our current

play01:23

apis this means applying Ed memo use

play01:25

callback and memo apis to manually tune

play01:28

how much react reenders on St changes so

play01:30

if you have an element that you don't

play01:32

want to have render because the things

play01:34

you're passing to it didn't change but

play01:35

maybe a hook above that did you could

play01:37

memorize the component you can memorize

play01:39

the data there's a lot of places you can

play01:41

throw these checks to keep those updates

play01:43

from happening but even knowing that you

play01:44

can do that much less how to do it and

play01:46

how to do it properly is a big ask for a

play01:48

Dev that's just trying to have an input

play01:50

field that responds when they type I'm

play01:52

very thankful to know that in the future

play01:54

they won't have to do that without

play01:55

having to adopt a whole different mental

play01:57

model like signals oh look at that

play01:59

they're saying the same thing here

play02:00

manual memoization is a reasonable

play02:01

compromise but we weren't satisfied our

play02:03

vision is for react to automatically

play02:05

render just the right parts of the UI

play02:07

when State changes without compromising

play02:08

a react Coral model first part is yeah

play02:12

that's solid JS you can use other things

play02:14

for this but wait without compromising

play02:15

react's core mental model there's the

play02:17

difference spelt and solid and all these

play02:19

other Solutions have their own gotas

play02:21

with how state is encapsulated how you

play02:23

have to call things instead of using

play02:24

values how equals is bound to weird

play02:26

behaviors and spth all these types of

play02:28

things that react as a pretty good job

play02:30

of sidest stepping where I still feel

play02:32

like react feels the most like just

play02:34

JavaScript of modern Frameworks solid is

play02:36

really close but react still as the the

play02:39

most JS Vibe I get and that's a huge

play02:42

part of their core mental model as well

play02:44

as the composability of all these pieces

play02:45

in the way that those interface together

play02:47

back to the post we believe that reacts

play02:49

approach UI is a simple function of

play02:51

state with standard JavaScript values

play02:53

and idioms is a key part of why react

play02:55

has been approachable for so many

play02:56

developers that's why we've invested in

play02:58

building an optimized compiler for react

play03:01

JavaScript is a notoriously challenging

play03:02

language to optimize thanks to its loose

play03:04

rules and dynamic nature react compiler

play03:06

is able to compile code safely by

play03:08

modeling both the rules of JavaScript

play03:10

and the rules of react for example react

play03:12

components must be item potent returning

play03:14

the same value given the same inputs and

play03:16

they can't mutate props or state values

play03:18

these rules limit what developers can do

play03:20

and help to carve out a safe space for

play03:21

the compiler to optimize within of

play03:23

course we understand that developers

play03:25

sometimes bend the rules a bit and our

play03:27

goal is to make react compiler work out

play03:28

of the box on his as much code as

play03:30

possible the compiler attempts to detect

play03:32

when code doesn't strictly follow

play03:33

react's rules and will either compile

play03:35

the code where safe or skip compilation

play03:37

if it isn't safe we're testing against

play03:38

meta's large and varied code base in

play03:40

order to help validate this approach

play03:42

there is so much good information in

play03:45

here so first off lint rules as a way to

play03:48

make the code more optimizable that's a

play03:50

bit scary we've all had lint rules that

play03:52

prevent you from doing things that are

play03:53

obviously not performant or have weird

play03:55

side effects but the idea of lint rules

play03:57

that are specifically to keep you within

play03:58

the bounds of the Java JavaScript that

play04:00

the react compiler is the most capable

play04:02

of optimizing that's an interesting

play04:04

concept like genuinely really

play04:06

interesting and I'm curious how that

play04:07

plays out the other part is that a lot

play04:09

of your code isn't going to fall within

play04:11

that optimizable set and when that

play04:13

happens you can't just opt out of the

play04:15

compiler entirely like how do you deal

play04:17

with that I'm sure there's a lot of code

play04:19

in the Instagram code base period but

play04:22

importantly here there's a lot of code

play04:23

in the Instagram codebase that probably

play04:24

doesn't follow these rules exactly and

play04:26

that's why this call out is so important

play04:28

because if it works there and able to

play04:30

make it work around those things maybe

play04:31

you don't get the same performance win

play04:33

but at least it's compatible that's huge

play04:35

and historically react's been really

play04:36

good about this in the past in the past

play04:39

other Frameworks like angular when they

play04:40

had major updates from angular js1 to

play04:43

angular 2.0 you couldn't just use old

play04:45

code in my always betting on react video

play04:47

I did last year I gave the example of

play04:49

taking a component from this blog from

play04:51

2014 and putting it in a brand new app

play04:54

router nextjs RSC project and actually

play04:57

server rendering that ancient class

play04:59

component react's historically been

play05:00

incredibly backwards compatible which is

play05:02

a huge part of why Hooks could take off

play05:04

the way they did because I could just

play05:05

update react versions all the old code

play05:07

still worked but I could make new

play05:08

components with hooks and even Mount old

play05:10

components with classes inside of those

play05:12

new components and intermingle them

play05:14

effortlessly that's how I do things with

play05:16

server components largely too it's

play05:17

surprisingly easy to take code from the

play05:19

old era and use it in this new stuff and

play05:21

it all just works together like the Lego

play05:22

bricks they built but if the compiler is

play05:24

strict about what things it does and

play05:26

doesn't support that all gets thrown

play05:27

away which is why it's very good to hear

play05:29

their building outs into the compiler

play05:31

for developers who are curious about

play05:32

making sure their code follows reacts

play05:34

rules we recommend enabling strict mode

play05:37

and configuring react's eslint plugin

play05:39

these tools can help catch subtle bugs

play05:40

in your react code improving the quality

play05:42

of your applications today and future

play05:44

proofs your applications for upcoming

play05:45

features such as react compiler there's

play05:47

going to be all the crazy like rules of

play05:48

hooks and such I should do a longer Deep

play05:51

dive on why those are important there

play05:52

are some crazy optimizations with hooks

play05:54

that yall don't even know about anyways

play05:56

we're also working on Consolidated

play05:57

documentation of the rules of react and

play05:59

up updates to our esent plugin to help

play06:00

teams understand and apply these rules

play06:02

to create more robust apps really good

play06:04

to hear that they're committed to making

play06:05

esent experience much better previously

play06:07

the react team hasn't been as focused on

play06:08

these types of tools that are external

play06:10

ecosystem things like es lint being

play06:12

mentioned this much in a react post is

play06:14

interesting to see even things like JS

play06:16

do comments on the type definitions

play06:18

aren't particularly interesting to the

play06:19

react core team things like that tend to

play06:21

fall on the shoulders of poor Matt pook

play06:23

who's stuck making all of those

play06:24

definitions himself but God bless him

play06:26

for it those are going to be a very nice

play06:27

IDE win see the compiler and action you

play06:30

can check out our talk from last Fall

play06:31

Again check out my video where I show

play06:33

the cas this if you want to learn more

play06:34

about it time of the talk we had early

play06:36

experimental data from trying react

play06:37

compiler on one page of Instagram since

play06:39

then we've shipped the compiler to

play06:41

production across all of instagram.com

play06:43

we've also expanded our team to

play06:44

accelerate the roll out to additional

play06:45

services at meta and to open source

play06:47

we're excited about the path ahead and

play06:48

we'll have more to share in the coming

play06:49

months oh boy I cannot wait for this to

play06:51

be open sourced I am so curious about

play06:54

the actual implementation details here

play06:56

it's going to be a fun ride speaking of

play06:59

fun ride let's talk about actions which

play07:00

have been a particularly wild ride for

play07:02

me we previously shared that we were

play07:03

exploring solutions for sending data

play07:05

from the client to the server with

play07:06

server actions so that you can execute

play07:08

database mutations and Implement forms

play07:10

that's weird to reduce it to these two

play07:12

examples there's a lot of other things

play07:13

you want to do with an action I get what

play07:14

you're saying though the idea of having

play07:16

a a proper built-in primitive for the

play07:18

client to send the data to the server

play07:20

important stuff during development of

play07:22

server actions we extended these API to

play07:23

support data handling in client-only

play07:25

applications as well oh boy they're

play07:27

formally blessing the use case of using

play07:29

server actions for client stuff huh we

play07:33

refer to this broader collection of

play07:35

features as simply actions actions allow

play07:37

you to pass a function to Dom elements

play07:39

such as form huh so this is for react L

play07:42

JavaScript in a way hm the action

play07:46

function can operate synchronously or

play07:48

asynchronously you can Define them on

play07:49

the client side using standard

play07:51

JavaScript or on the server side with

play07:53

you server directives when using an

play07:54

action react will manage the life cycle

play07:56

of the data submission for you providing

play07:58

hooks like use form status or use form

play08:00

state to access the current state and

play08:01

response of the form action by default

play08:04

actions are submitted within a

play08:05

transition keeping the current page

play08:06

interactive while the action is

play08:08

processing since actions support async

play08:10

functions we've also added the ability

play08:11

to use async and await within the

play08:13

transitions this allows you to show

play08:14

pending UI with the is pending state of

play08:16

a transition when an async request like

play08:18

fetch starts and show the pending UI all

play08:20

the way through the update being applied

play08:22

I'll be honest the examples I've seen

play08:24

thus far for use form status and use

play08:26

form state are really hard to digest it

play08:28

feels a little bit too much like magic

play08:30

at the moment I need to make some really

play08:31

good ones so I can both communicate it

play08:34

better and confidently show it in my

play08:36

videos just know if these hooks make you

play08:38

feel a little dumb right now you're not

play08:39

alone not only am I struggling to share

play08:41

how they work as like an educator I

play08:43

haven't really implemented them my apps

play08:45

just yet so yeah if anyone on the r team

play08:47

wants to bully me into using them let me

play08:49

know use optimistic however also very

play08:51

confusing I have used it it's really

play08:53

powerful alongside actions we're

play08:54

introducing a feature named use

play08:55

optimistic for managing optimistic State

play08:57

updates within this hook you can apply

play08:59

temporary updates that are automatically

play09:00

reverted once the final State commits

play09:02

for actions this allows you to

play09:03

optimistically set the final state of

play09:05

the data on the client assuming the

play09:07

submission is successful and revert to

play09:08

the value of the data received from the

play09:10

server it works using regular asyn a we

play09:12

so it works the same whether you're

play09:13

using fetch on the client or a server

play09:15

action from the server Library authors

play09:16

can Implement custom action equals

play09:18

function props in their own components

play09:20

with used transition our intent is for

play09:21

libraries to adopt the actions pattern

play09:23

when designing their component apis to

play09:25

provide a consistent experience for

play09:26

react Developers for example if your

play09:28

library provides a calendar on select

play09:30

event handler component consider also

play09:32

exposing a select action equals action

play09:34

API too this is really interesting I'm

play09:36

I'm starting to see what they're going

play09:37

for here right now if I have a component

play09:39

that has a loading state in it and I

play09:41

want to use that loading state to render

play09:43

something differently above it that kind

play09:45

of sucks to do you have to have crazy

play09:48

call backs that are embedded in that

play09:49

component the call back estate selector

play09:51

in your parent in order to do all of

play09:52

this now instead of that the actual

play09:54

action I send to the thing is also

play09:56

capable of doing the updating and

play09:58

triggering that all the way up the tree

play10:00

as far as I need to wherever it's going

play10:02

to hit that use form status or use form

play10:04

state or whatever of these helpers and

play10:06

it means that these generics built into

play10:07

react now have behaviors that interface

play10:10

with children automatically that's

play10:12

interesting I'm starting this is

play10:13

starting to click for me while we

play10:15

initially focused on server actions for

play10:17

client side data transfer our philosophy

play10:18

for react is to provide the same

play10:20

programming model across all platforms

play10:22

and environments when possible if we

play10:23

introduce a feature on the client we aim

play10:25

to make it also work on the server and

play10:27

vice versa this philosophy allows us to

play10:28

create a single set of apis that work no

play10:30

matter where your apps run making it

play10:32

easier to upgrade to different

play10:34

environments later that's a interesting

play10:35

way of putting it I kind of thought of

play10:37

actions less as a react API more of a

play10:39

recommended pattern where it's the the

play10:41

method in which you bind things from the

play10:44

server to the client so such that the

play10:45

client can update them and send data to

play10:47

the server it felt like it was

play10:49

describing that relationship more than

play10:50

it was describing the actual behavior of

play10:52

the API it's interesting to see them

play10:54

really double down on the API and how it

play10:56

works within react I'm going to have to

play10:57

play with this a lot lot more I really

play11:00

feel like I need to understand those

play11:01

hooks better so uh make sure you like

play11:03

this video and you give me a

play11:03

subscription because that's going to

play11:05

take a lot of work new features in the

play11:07

react Canary we've introduced react

play11:09

canaries as an option to adopt

play11:11

individual new stable features as soon

play11:13

as their design is close to final before

play11:14

they released in a stable sver version

play11:16

canaries are a change to the way we

play11:18

develop react previously features would

play11:20

be researched and built privately inside

play11:22

of meta so users would only see the

play11:23

final polished product when released to

play11:25

stable with canaries we're building in

play11:27

public with the help of the community to

play11:28

final features we share in the react

play11:30

Labs blog Series this means you hear

play11:32

about new features sooner as they're

play11:33

being finalized instead of after they're

play11:35

complete this is also huge because the

play11:37

community can give a bunch of feedback

play11:39

and push back on things like the

play11:40

original RFC for Server components was

play11:42

not great I didn't care I even in my

play11:44

original video called out how dumb it

play11:46

was that you couldn't async await and

play11:48

just await a DB call inside of a server

play11:50

component and they ended up rewriting

play11:52

the proposal and making the whole thing

play11:53

async A8 based without weird file

play11:55

pathing these improvements only happen

play11:57

if the community is involved in the

play11:58

process otherwise there would be too

play11:59

much commitment on a specific way of

play12:01

doing things that no longer make sense

play12:03

this is a huge part of how react will

play12:05

continue to win and it's awesome that

play12:06

they're letting the community be

play12:07

involved it sucks that this has also

play12:09

resulted in some fud where people feel

play12:10

like you have to use a canary if you

play12:12

want the new react features no you can

play12:14

use the new react features when they're

play12:15

stable but if you're willing to be part

play12:16

of this experiment where we're learning

play12:18

and figuring out all these pieces you

play12:20

want to be there as we figure it out and

play12:21

finalize it you can be now and there's a

play12:23

whole process and opportunity here to do

play12:26

just that and next was one of the few

play12:27

that really jumped on that opportunity

play12:29

server components asset loading document

play12:31

metadata and actions have all landed in

play12:33

the react Canary and we've added docs to

play12:35

these features on react. deev the

play12:37

directives we've talked about a bunch I

play12:39

will very quickly say people seem to

play12:41

think these two are like opposites of

play12:43

the same thing where use servers for

play12:44

Server components use clients for client

play12:45

components they're not don't think that

play12:47

check out any of my videos about server

play12:49

actions in particular because these are

play12:50

for functions that the client calls that

play12:52

are on the server so if I want to post

play12:54

things to a for or update my user

play12:56

metadata or something like that use

play12:58

servers for that that use client is when

play13:00

I want the component to ship JavaScript

play13:02

to the client so this is I want to ship

play13:03

JavaScript to the client this is I want

play13:05

the client to be able to ship data to

play13:07

the server these aren't opposites

play13:08

they're different behaviors entirely and

play13:09

they're bundler features that happen to

play13:11

be built around react that doesn't mean

play13:13

only react can use them in fact solid is

play13:15

starting to build U server into solid

play13:17

start which is so cool to see other

play13:19

Frameworks adopting the opportunities

play13:21

here they Mark the split points between

play13:23

the two environments use client

play13:24

instructs the bundler to generate a

play13:25

script tag similar to Aster's islands

play13:28

where use tells the bundler to generate

play13:30

a post environment like trpc mutations

play13:32

I'm going to take a little moment of

play13:34

Pride here the reason trpc made it here

play13:36

is because trpc became a popular thing

play13:39

that nerds like us talk about to discuss

play13:41

modern best practices for full stack

play13:44

webd trpc mutations and specifically

play13:46

trpc got its first big break when I

play13:48

started chilling it really hard and it's

play13:50

so cool seeing trpc go from that weird

play13:53

side project that I heard somebody

play13:54

working on that originally came from the

play13:56

guy who made Zed and got taken over by

play13:57

Alex who pushed it incredibly far just a

play14:00

typesafe way to write server functions

play14:01

and call them in react query and now

play14:03

it's this legendary moment of time where

play14:05

we realize that the way we were

play14:07

communicating between the server and

play14:08

client was not ideal so much so that

play14:10

it's being cited next to Astro in the

play14:13

react blog post about what they're doing

play14:15

it's so cool Dan abov himself even

play14:17

tweeted basically this he probably wrote

play14:19

this part to be honest he specifically

play14:20

said that Astro islands are used client

play14:23

and trpc mutations are you server which

play14:25

is very good mapping if you know how

play14:26

these two things work together they let

play14:28

you write reusable components that

play14:30

compose client side interactivity with

play14:32

the related server side logic yes very

play14:34

very cool stuff it's once it clicks it

play14:36

you can't go back document metadata is

play14:38

an interesting addition here too we've

play14:40

added built-in support for rendering

play14:41

title meta and metadata link tags

play14:44

anywhere in your component tree these

play14:45

work the same way in all environments

play14:46

including fully client side code SSR and

play14:49

RSC this provides built-in support for

play14:50

features pioneered by libraries like

play14:52

react helmet yeah RP helmet in all the

play14:54

libraries that like did these things

play14:56

differently if you're curious why this

play14:58

matters it's cuz these all are supposed

play15:00

to go in head which isn't your body

play15:01

which is where react normally renders so

play15:03

if you want to render a title in your

play15:05

component where does that go when these

play15:07

are part of the framework it will handle

play15:08

that and throw it in the right place

play15:10

that's why right helment was previously

play15:11

so valuable because it would take the

play15:13

thing you put in your jsx rendered in

play15:15

the virtual Dom and instead of putting a

play15:17

similar element in the real Dom it just

play15:18

writes it to head instead that's why

play15:19

it's helmet you can put it anywhere and

play15:21

it goes on top asset loading we

play15:23

integrated suspense with the loading

play15:25

life cycle of resources such as

play15:26

stylesheets fonts and Scripts so that

play15:28

react takes them into account to

play15:30

determine whether the content in

play15:31

elements like a style a link or a script

play15:33

are ready to be displayed we've also

play15:35

added new resource loading apis like

play15:37

preload and preinit to give greater

play15:38

control for when a resource should load

play15:40

and initialize this is some remix stuff

play15:43

what's cool here is now if you were to

play15:45

use suspense to wrap your page because

play15:47

you didn't want to have things flash in

play15:49

not only is suspense going to wait for

play15:51

when the components get stream down it's

play15:53

also going to wait for when your style

play15:54

tags or similar things load in so you

play15:57

won't have that flash of uny content

play15:59

anymore because it won't flip to the new

play16:01

content until the style tag is loaded

play16:03

this is really cool and the fact that

play16:05

they expose it as a generic API where

play16:07

I'm assuming you can just declare

play16:08

anything as a resource yeah such as

play16:11

script Styles sheets and fonts as soon

play16:12

as you know you need them that's really

play16:14

cool so you can specify in other places

play16:17

that this might be needed in the future

play16:18

and preload it so that it's ready to go

play16:20

when you make those transitions good

play16:22

stuff I'm really happy that they're like

play16:24

more deep in the documentation of these

play16:25

things that's been a very reasonable

play16:27

critique of this up until now where like

play16:29

there's all these new things happening

play16:30

we're seeing them on Twitter we're

play16:31

seeing them in next but we don't know

play16:32

how to use them where's the docs finally

play16:34

we have some docs being linked actions

play16:37

as shared above we've added actions to

play16:39

manage sending data from the client to

play16:40

the server you can add actions to an

play16:42

element like a form you can access their

play16:43

status with use form status you can

play16:45

handle their result with use form State

play16:46

and even optimistically update with use

play16:48

optimistic when you put it that way it

play16:49

sounds easy but uh the behavior of these

play16:51

things is not as simple as I would like

play16:53

more coming soon since all these

play16:54

features work together it's difficult to

play16:56

release them in the stable Channel

play16:57

individually for example example

play16:58

releasing actions without the

play16:59

complimentary hooks for accessing the

play17:01

form states that would just limit the

play17:03

Practical usability of actions

play17:04

introducing server components without

play17:06

integrating server actions would

play17:07

complicate modifying data on the server

play17:09

as someone who shipped server components

play17:11

without server actions God bless trpc

play17:13

before we can release a set of features

play17:14

to the stable Channel we need to ensure

play17:16

they work cohesively and developers have

play17:18

everything they need to use them in

play17:19

production react canaries allow us to

play17:21

develop these features individually and

play17:23

release the stable apis incrementally

play17:24

until the entire feature set is complete

play17:26

the current set of features in react

play17:27

canary are complete and ready to release

play17:30

the next major version of react the

play17:33

thing we are all here for after a couple

play17:35

of years of iteration react at Canary is

play17:38

now ready to ship to react at latest the

play17:40

new features mentioned above are

play17:41

compatible with any environment your app

play17:43

runs in providing everything needed for

play17:45

production use since asset loading and

play17:47

document metadata may be a breaking

play17:48

change for some apps the next version of

play17:50

react will be a major version react 19

play17:52

there's still more to be done preparing

play17:54

for release in react 19 we're also

play17:56

adding long requested improvements which

play17:58

require breaking changes like support

play18:00

for web components can't believe they're

play18:01

actually doing this they've been punting

play18:03

the ball on web components for so long

play18:05

and I get why because they don't really

play18:07

fit the react model great but sometimes

play18:09

you have some crappy web component from

play18:10

some third party provider like you're I

play18:12

don't know your rate this out of five

play18:14

that goes to some third party being able

play18:16

to quickly embed that when everything

play18:17

else is react that's nice I see why

play18:19

they're finally caving here our Focus

play18:21

now is to land these changes prepare for

play18:23

release finalize docs for new features

play18:25

and publish announcements for what's

play18:27

included we'll share more information

play18:28

about everything react 19 includes how

play18:30

to adopt the new client features and how

play18:32

to build support for Server components

play18:33

in the coming months I haven't heard the

play18:34

mention off screen screen in a while oh

play18:36

boy this is a fun one it's been renamed

play18:38

which is a good decision offscreen is

play18:40

two in the weeds technically what the

play18:42

hell are we talking about well let's

play18:43

dive in since our last update we've

play18:45

renamed a capability we're researching

play18:46

from offscreen to activity the name

play18:48

offscreen implied that it only applies

play18:50

to parts of the app that were not

play18:51

visible but while researching the

play18:52

feature we realize it's possible for

play18:54

parts of the app to be visible and in

play18:55

active such as content behind a modal

play18:57

the new name more closely reflects the

play18:59

behavior of making certain parts of the

play19:01

app active or inactive activity is still

play19:03

under research and our remaining work is

play19:05

to finalize The Primitives that are

play19:06

exposed to library developers we've de

play19:08

prioritized this area while we focus on

play19:10

shipping features that are more complete

play19:11

I'm happy they they called this out

play19:13

because offscreen has not been mentioned

play19:14

much the best I will poorly teal the art

play19:16

here is it gives you a way to run things

play19:18

in the background such that they're not

play19:20

blocking the main react thread but

play19:22

they're still going on so when you

play19:23

change views like you have a canvas

play19:25

that's been hidden updating in the

play19:27

background and then it reappears that

play19:29

it's synced already without having to

play19:30

render everything you can keep running

play19:32

the virtual Dom without having the real

play19:34

Dom update until you choose for the real

play19:35

Dom to update kind of in its own thread

play19:37

it's it's a lot in addition to this

play19:39

update our team has presented at

play19:41

conferences and made appearances on

play19:42

podcast to speak more on our work and

play19:44

answer questions really good stuff here

play19:46

the two reacts post I have a video about

play19:47

that that was really good too lots of

play19:49

cool stuff here I need to pull these

play19:50

people on the show more normally I just

play19:52

DM them a bunch and then shout at a

play19:53

camera later on but this is a great post

play19:56

really thankful they've been writing

play19:57

these again h shout out to the whole

play19:59

team everybody involved both with the

play20:00

communication of these things as well as

play20:02

actually making these changes possible

play20:04

well uh that was quite an update let me

play20:06

know what you guys think in the comments

play20:08

and until next time see you later peace

play20:10

nerds

Rate This

5.0 / 5 (0 votes)

関連タグ
React新機能将来展望コンパイラパフォーマンスコード最適化リアクティブプログラミングWeb開発技術アップデートJavaScript