React 19 Is Here - Are You Ready?

Theo - t3․gg
16 Feb 202420:11

Summary

TLDRThe video script provides an insightful analysis of the latest updates from the React core team regarding React 19 and the React compiler. It delves into the exciting new features like the React compiler, actions, use optimistic, server actions, and more. The script highlights the team's efforts to optimize React's performance, streamline developer experience, and foster community involvement through React Canaries. With a blend of technical insights and enthusiasm, the script builds anticipation for the upcoming release of React 19 and the open-sourcing of the React compiler, promising a future filled with groundbreaking advancements in the world of React.

Takeaways

  • 😮 React is introducing a new compiler that will automatically optimize rendering without the need for manual memoization techniques like useMemo and useCallback.
  • 🔭 The React compiler aims to optimize code while respecting the rules of React and JavaScript, attempting to compile as much code as possible safely.
  • 🚦 React is promoting the use of strict mode, ESLint, and consolidated documentation to help developers write code that adheres to React's rules for better optimization.
  • 🌐 React is working on making their APIs consistent across client and server environments, with features like Actions that can handle data transfer in both contexts.
  • 🎉 React Canaries allow developers to adopt new stable features earlier and provide feedback before final release, fostering community collaboration.
  • 🔀 Server Actions, a new feature in the React Canary, provide a built-in way to manage data submission between the client and server.
  • 🧠 React is introducing new hooks like useFormStatus, useFormState, and useOptimistic to work with Actions and manage form state and optimistic updates.
  • 📄 React 19 will include support for rendering document metadata (title, meta, link tags) directly in components, simplifying the process.
  • ⏳ React is integrating Suspense with resource loading (stylesheets, fonts, scripts) to prevent flashes of unstyled content during transitions.
  • 🌐 React 19 will also include long-awaited support for Web Components, allowing better integration with third-party components.

Q & A

  • What is the main topic of the video script?

    -The video script discusses upcoming changes and new features in React, such as the React compiler, actions, use of canaries for early feature adoption, and improvements planned for React 19.

  • What is the purpose of the React compiler?

    -The React compiler is a new feature that aims to automatically render just the right parts of the UI when state changes, without requiring manual memoization techniques like useMemo and useCallback. It models the rules of JavaScript and React to optimize rendering.

  • What are actions in React, and how do they work?

    -Actions allow you to pass functions to DOM elements like forms, managing the lifecycle of data submission. React provides hooks like useFormStatus and useFormState to access the state and response of form actions. Actions can be defined on the client or server side.

  • What are React canaries, and why are they being introduced?

    -React canaries allow developers to adopt individual new stable features as soon as their design is close to final, before they are released in a stable version. This enables public development and community feedback on features before they are complete.

  • What are some of the new features introduced in the React canary?

    -New features in the React canary include server components, asset loading, document metadata, actions for managing client-to-server data, and related hooks like useFormStatus and useFormState.

  • What is the difference between 'use server' and 'use client' directives?

    -'use server' instructs the bundler to generate a post environment for server-side functions, while 'use client' instructs the bundler to generate a script tag for client-side code, similar to Astro's islands.

  • What is the purpose of the 'document metadata' feature?

    -The document metadata feature provides built-in support for rendering title, meta, and link tags anywhere in the component tree, working across all environments, including client-side, SSR, and RSC.

  • What is the 'activity' feature (formerly called 'offscreen'), and what is its purpose?

    -The 'activity' feature, formerly called 'offscreen,' aims to make certain parts of the app active or inactive, allowing them to run in the background without blocking the main React thread. It's still under research.

  • What major changes are expected in React 19?

    -React 19 will be a major version release, including support for web components and other long-requested improvements that may introduce breaking changes.

  • What is the overall approach of the React team regarding new features and releases?

    -The React team aims to provide a consistent programming model across all platforms and environments. They are also emphasizing public development and community feedback through canaries before finalizing and releasing new features.

Outlines

00:00

🔥 React's Big Changes: Goodbye to useMemo, useCallback, and More

The paragraph discusses major upcoming changes in React, where certain hooks and APIs like useMemo, useCallback, memo, forwardRef, react.lazy, useContext, and context providers will be replaced or made obsolete. The post from the React core team explains that manual memoization will no longer be necessary as the React compiler will automatically optimize rendering. The changes aim to simplify the React development experience without compromising its core mental model or JavaScript idioms.

05:01

🧪 React Compiler: Optimizing Rendering Without Manual Memoization

This paragraph delves into the React compiler, which is no longer a research project. The compiler aims to automatically optimize rendering without requiring manual memoization techniques like useMemo and useCallback. It models both JavaScript and React rules to safely compile and optimize code. The compiler will attempt to work with existing code, even if it doesn't strictly follow React's rules. The React team is testing the compiler against Meta's large codebase to validate this approach and plans to provide documentation and ESLint rules to help developers write optimizable code.

10:02

🚀 Actions: A New Way to Handle Client-Server Data Transfer

The paragraph introduces Actions, a new feature that provides a consistent way to send data from the client to the server. Actions can be used for both client-side and server-side operations, and React will manage the lifecycle of data submissions. The post discusses hooks like useFormStatus, useFormState, and useOptimistic, which allow developers to access the current state and response of form actions. The team aims for libraries to adopt the Actions pattern to provide a consistent experience for React developers.

15:04

🌐 React Canary: Early Access to New Stable Features

This paragraph discusses React Canaries, a new way for developers to adopt individual new stable features before their official release. Canaries allow the React team to build features in public with community feedback, leading to improvements like the async/await support in Server Components. The current set of features in React Canary, including Actions, document metadata, and asset loading, are ready for the next major version, React 19. The team is also preparing for breaking changes like web component support.

20:04

🔍 Activity (Formerly Offscreen): Prioritizing App Parts

The paragraph mentions the renaming of the 'offscreen' capability to 'activity,' reflecting its broader applicability beyond just offscreen elements. Activity aims to allow developers to make certain parts of the app active or inactive, potentially running in the background without blocking the main React thread. The team has de-prioritized finalizing this feature while focusing on shipping more complete features.

Mindmap

Keywords

💡React Compiler

The React Compiler is a new feature that aims to automatically optimize how React renders components based on state changes, reducing unnecessary re-renders and improving performance. It analyzes the structure and rules of React components to safely optimize the rendering process. The compiler attempts to handle code that doesn't strictly follow React's rules, making it compatible with existing codebases. This feature is intended to eliminate the need for manual memoization techniques like `React.memo` or `useMemo`.

💡Actions

Actions are a new set of features in React that provide a unified way to handle data transfer between the client and server. They allow developers to pass functions to DOM elements like forms, which can operate synchronously or asynchronously. Actions can be defined on the client-side using JavaScript or on the server-side with server directives. React manages the lifecycle of data submission for actions, providing hooks like `useFormStatus` and `useFormState` to access the current state and response. Actions support async/await and can be used with transitions to show pending UI during asynchronous requests.

💡React Canary

React Canary is a new way for React to introduce and develop new features in public, with the help of the community. Instead of building features privately and releasing them only when complete, React Canary allows developers to adopt individual new stable features as soon as their design is close to final. This approach encourages community feedback and input during the development process, helping to refine and improve new features before their stable release. Examples of features available in the React Canary include server components, asset loading, document metadata, and actions.

💡Server Components

Server Components is a new feature in React that allows developers to render components on the server instead of the client. This can improve performance by reducing the amount of JavaScript that needs to be sent to the client, and can also enable new use cases such as rendering content that requires server-side data or logic. Server Components can be used in combination with Client Components, allowing developers to selectively render parts of their application on the server or client as needed.

💡ESLint Plugin

The React team is working on updating their ESLint plugin to help developers understand and apply the rules of React. This plugin will include lint rules that ensure code follows the constraints and guidelines required for optimal performance with the React Compiler. By configuring this plugin, developers can catch subtle bugs and improve the quality of their React applications, while also future-proofing their code for upcoming features like the React Compiler.

💡Activity (formerly Offscreen)

Activity, formerly known as Offscreen, is a feature under research by the React team. It aims to provide a way to make certain parts of the application active or inactive, allowing React to continue running and updating the virtual DOM for inactive components without affecting the main thread or rendering to the real DOM. This feature could enable scenarios like updating content behind a modal or keeping a hidden canvas synchronized without blocking the main UI thread.

💡Web Components

React 19 will include support for Web Components, which are reusable custom elements that can be used across different frameworks and libraries. This change addresses a long-standing request from developers who need to integrate third-party Web Components into their React applications. By adding Web Component support, React will be able to render and interact with these custom elements more seamlessly.

💡Asset Loading

React now integrates with the loading lifecycle of resources like stylesheets, fonts, and scripts, allowing Suspense to wait for these assets to load before rendering content. This feature aims to prevent the 'flash of unstyled content' problem that can occur when styles are loaded after the initial render. React also provides new APIs like `preload` and `preinit` to control when resources should load and initialize, enabling more efficient asset management.

💡Document Metadata

React now includes built-in support for rendering `<title>`, `<meta>`, and `<link>` tags anywhere in the component tree. This functionality, previously provided by libraries like React Helmet, allows developers to manage document metadata directly within their React components, regardless of the rendering environment (client-side, server-side rendering, or React Server Components).

💡Transitions

Transitions are a feature in React that allows developers to manage the state of asynchronous operations, such as fetching data or submitting forms. By default, actions (another new feature) are submitted within a transition, keeping the current page interactive while the action is processing. Transitions also support async/await, enabling developers to show pending UI while an async request is in progress and update the UI once the request completes.

Highlights

Andrew Clark from the React core team suggests significant updates for React, including changes to useMemo, useCallback, memo, forwardRef, React.lazy, useContext, throw promise, and context providers.

Existing React functionalities won't be deprecated, but future versions may not require current practices, hinting at a shift in React's development approach.

The introduction of React Compiler, transitioning from a research project, aims to reduce unnecessary re-renders by optimizing memoization and component updates.

React's core team emphasizes the importance of React being approachable and maintaining its core mental model amidst these updates.

The React Compiler is designed to safely compile code by understanding both JavaScript and React's rules, enhancing performance.

Lint rules will play a significant role in making code more optimizable for the React Compiler, signaling a shift towards more constrained coding practices for optimization.

React's approach to backward compatibility remains a priority, ensuring older code works seamlessly with new versions.

New updates like actions and useOptimistic are being explored to improve client-server interactions and state management.

React Canaries offer a new way for the community to test and give feedback on upcoming features before they're released in stable versions.

React's investment in a compiler and new features like actions shows a commitment to evolving the framework while keeping developer experience in focus.

Server actions are being developed to facilitate easier data transfer between client and server, potentially revolutionizing how forms and mutations are handled.

The React team is focusing on creating a cohesive set of features that work together seamlessly across client and server environments.

React 19 is announced as the next major version, promising compatibility across different environments and including long-requested improvements like web component support.

The shift towards open development with React Canaries allows the community to actively participate in shaping the future of React.

The introduction of document metadata and asset loading features in React aims to streamline the handling of resources and metadata in applications.

React's focus on consolidating documentation and improving tools like eslint plugin highlights an effort to enhance the developer experience and code quality.

The renaming of 'offscreen' to 'activity' indicates a refined approach to managing inactive parts of the application, showing React's continuous refinement of concepts.

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)

الوسوم ذات الصلة
ReactWeb DevelopmentJavaScriptFrameworkPerformanceDeveloper ExperienceServer ComponentsClient-Server CommunicationOptimizationsCommunity Feedback
هل تحتاج إلى تلخيص باللغة الإنجليزية؟