React 19 and the Compiler for the Rest of Us

Rate this content
Bookmark

FAQ

The compiler will not optimize library code unless it's compiled from source with support. It works fine as long as the libraries follow React rules and conventions.

The benefits include improved performance through deeper optimizations, reduced rendering times, and enabling developers to focus on application functionality rather than technical optimizations.

Developers should follow React rules strictly, avoid disabling ESLint rules unnecessarily, and be aware of potential issues with refs and custom hooks that might not align with standard React lifecycles.

The React compiler is important for performance optimizations and stacking abstractions. It helps translate high-level language code for better performance without requiring manual optimizations from developers.

One challenge is the removal of the global JSX namespace, which requires adjustments in applications using libraries like Emotion that have not yet updated to React 19.

Johnny's talk focuses on React 19 from an application engineer's perspective, emphasizing performance for applications where users spend multiple hours. The talk also covers React 19's compiler and its benefits.

The React compiler optimizes memorization by minimizing stack memory usage and efficiently handling components rendering, which helps in reducing memory usage on the stack.

Reported improvements include better load times, less rendering, and enhanced application performance, as experienced during the beta production phase at Sizzle.

Johnny, whose full German name is Johannes Bernhardt, is currently working at Synthesia and previously worked at Sizzle. He has significant experience with React 19, having used it in beta and with the compiler at both jobs.

Yes, using the React compiler can increase build times, especially if Babel wasn't used previously, due to additional parsing and processing overhead.

Johannes Goslar
Johannes Goslar
30 min
13 Dec, 2024

Comments

Sign in or register to post your comment.
Video Summary and Transcription
Hi everyone. I'm Johnny, an application engineer who builds user-centric React 19 applications. Today, our goal is to help you reach production mountain with React 19. Let's start by gathering a crew and discussing the motives for installing the compiler. We'll revisit React rules and explore the compiler's impact on code. The React compiler translates from JavaScript to JavaScript and provides error reporting. It enables deeper levels of optimization and focuses on user experience. To upgrade to React 19, install the latest version and be aware of any compatibility issues. Check if any custom runtime code needs to be disabled. The React compiler can be used with versions 17 or 18 if you have runtime support. The compiler removes use memos and optimizes the initialization process based on static components. It provides granular reactivity and reduces rendering, making the application feel quicker. Follow React rules and conventions to ensure compatibility. Test custom hooks, be aware of the impact on build time, and address any unexpected issues like the removal of the global JSX namespace. Debugging tools and source mapping in Chrome are useful for understanding compiler output. Enjoy translating chants and exploring the possibilities of React 19!

1. Introduction to React 19 and the Compiler

Short description:

Hi everyone. I'm Johnny, an application engineer who builds user-centric React 19 applications. Today, our goal is to help you reach production mountain with React 19. Let's start by gathering a crew and discussing the motives for installing the compiler. We'll also explore memorization and then proceed with the installation.

Hi everyone. Really happy to be here to be talking about React 19 and the compiler for the rest of us. First quick note about me. I'm called Johnny. I mean, my full German name would be Johannes Bernhardt, but no one's using that. So just refer to Johnny if you want to speak to me later.

I'm currently working at Synthesia. Sizzle was a job before, but I'm combining my React 19 experience of both jobs because at Sizzle we used React 19 quite early, put in the beta, put in the compiler. So running production at Synthesia, we are just now moving to using the compiler in some places and the React 19 port later.

You might ask, well, what does the rest of us mean? Rest of us in this case means I'm just talking about React 19 as an application engineer who's building applications where the user will spend multiple hours in. So it's not from e-commerce perspective where it counts the milliseconds for us. It's really important. Does the user have a good performance experience after being on the page for six hours maybe? And so it's all focused on that. And we're going to talk a bit about the compiler, but also doing a talk on my own would be a bit boring. So I did bring some support like the people before, but not in person. Greetings. I am Bernhardt III and love defending my performance castle by well-placed memorization. Hi there, mate. I am John Rackham and I write my code like I live, wild and free. Well, and I think the three of us together will cover like a wild range of experience looking into React 19.

So what's our goal for today? Well, our goal is simple. We want to help you reach production mountain with React 19, but before we can set sail, I'm going to first step, we need to get a crew together. So I'm going to ask some questions to the audience just to see where are we with React 19 already or not. Then we're going to talk about motives. Why would you want to install like the compiler into your code base? I mean like JavaScript is slow enough in the build process anyway. And then we just have a quick back to vintage islet. We're going to talk about memorization because if you add in compiler to add memorization, we probably want to know memorization in depth. Then we're just going to go for it. We just going to install React 19. We're going to see what happened to our code base.

2. Revisiting React Rules and Exploring the Compiler

Short description:

We'll revisit React rules and explore the compiler's impact on code. We'll also discuss motives for adding a compiler to an application. Let's take a step back to the 80s and learn about compilers' role in translating code from one language to another.

Then we learn something again about React rules and that sometimes not disabling lint rules is well the better idea. And so we're going to have a quick look back into the rules of React. Then we do the compiler climb. Compiler climb means we just look at two or three examples to see what does a compiler do to this code. And then we are on production mountain and then we sing a song. Well, I hope to get some support in the end because we're a crew now so we're going to sing some chanties. So let's do it.

Okay. Questions for the crew first. Who's team night? Who's adding use callbacks everywhere like big shout please. Okay. Well, that's not that many people. Who's team privateer? Team pirate? No, no? Okay. Well, and who's still using React 17 in his code base all over? Well, I'm talking about React 19. But maybe get to 18 first. But there's some good news for you at the end as well. And who's using 19 in production already? Because I mean, the release was last week. All right. Okay. Then I'm happy that I can share some experiences about that. All right, let's do it.

What might be motives adding a compiler to your application? I think let's take a step back to the 80s. There's this famous book called, well, the Red Dragon compiler book. They have like one quote I wanted to bring. I mean, like, oh, well, super interesting book. You can definitely check out if you just want to get a bit more about the computer science techniques. But the quote is simply stated a compiler is a program that can read a program in one language, the source language, and translate it into an equivalent program into another language, the target language. An important role of the compiler is to report any errors in the source program that it detects during the translation process. I think there's two or three very interesting points here. First is usually you use compilers to translate from one language into another.

QnA

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

React Compiler - Understanding Idiomatic React (React Forget)
React Advanced 2023React Advanced 2023
33 min
React Compiler - Understanding Idiomatic React (React Forget)
Top Content
Watch video: React Compiler - Understanding Idiomatic React (React Forget)
Joe Savona
Mofei Zhang
2 authors
The Talk discusses React Forget, a compiler built at Meta that aims to optimize client-side React development. It explores the use of memoization to improve performance and the vision of Forget to automatically determine dependencies at build time. Forget is named with an F-word pun and has the potential to optimize server builds and enable dead code elimination. The team plans to make Forget open-source and is focused on ensuring its quality before release.
Everything You Need to Know About React 19
React Summit US 2024React Summit US 2024
29 min
Everything You Need to Know About React 19
Watch video: Everything You Need to Know About React 19
React 19 introduces new features such as React Compiler and React Actions, which optimize code and provide better performance. The useOptimistic hook allows for optimistically updating UI, while the UseFormStatus hook tracks loading states and enables button disabling. The introduction of the 'action' attribute simplifies form handling and data retrieval. React 19 eliminates the need for useMemo and useCallback thanks to the React Compiler. The stability of React 19 has been observed in side projects without major issues.
What Refs Can Do for You
React Summit US 2024React Summit US 2024
27 min
What Refs Can Do for You
Today's Talk focused on using refs and profiling Agigrid in React. The speaker shared their experience with optimizing custom cell components and performance, including using memo and leveraging the React compiler. They also discussed improving performance with manual style updates and refactoring the use of useEffect. The speaker highlighted the use of ref callbacks, which can be implemented with useLayoutEffect. React 19 introduces changes to the ref callback approach. The Talk touched on using React DevTools and CSS variables for monitoring renders. It also discussed the compatibility of Azure Grid with React and the trade-offs between using React components and vanilla JavaScript. The speaker emphasized the importance of considering the DX improvements and the complexity of not seeing a React component tree in the dev tools. The Talk concluded with a mention of AG Grid features, handling refs at various levels, and the recommendation to consult with Stephen for technical questions and application architecture.
An App Developer's Guide to React 19: What You Need to Know and Everything You Can Safely Ignore
React Summit US 2024React Summit US 2024
33 min
An App Developer's Guide to React 19: What You Need to Know and Everything You Can Safely Ignore
Watch video: An App Developer's Guide to React 19: What You Need to Know and Everything You Can Safely Ignore
Today's Talk focused on React 19 and its features, APIs, changes, and optimizations. The speaker emphasized the importance of migrating apps and building with React 19. They discussed the high-level features of React 19, including TypeScript emphasis and the testing library philosophy. The Talk also covered the APIs and integration of React 19, as well as the changes and type safety it brings. The speaker highlighted the improvements in useReducer types and the use of TypeScript. They introduced useActionState for migrating code and the useOptimistic hook for maintaining state immediacy. Real-time updates, action functions outside components, and the benefits of using the 'use' prefix in React were also discussed. The Talk touched on upgrade considerations, the role of RSEs and server actions in React, and the current state of RSC development. Overall, the Talk provided valuable insights into the new features and enhancements in React 19 and their impact on the development process.
React Compiler - The Missing Piece for Optimizing React Applications
React Day Berlin 2024React Day Berlin 2024
30 min
React Compiler - The Missing Piece for Optimizing React Applications
Today's Talk introduces the React compiler and its optimizations in React 19. The compiler handles optimizations internally, allowing existing optimizations to coexist. React 19 also brings server components, enhanced hooks, improved reference handling, and asset loading optimization. The React compiler follows the same principles as a typical compiler, with a Babel plugin and ESLint plugin identifying optimizations. The compiler optimizes components by performing in-place updates and reducing unnecessary re-rendering. The React compiler playground helps understand the optimization process. Caching JSX and configuring the React compiler can further optimize specific components. The React compiler is compatible with React 18 and 17 with some configuration, but using React 19 is recommended. Connect with the speaker for more information and subscribe to their YouTube channel. Thank you for watching!

Workshops on related topic

Mastering React Server Components and Server Actions in React 19
React Advanced 2024React Advanced 2024
160 min
Mastering React Server Components and Server Actions in React 19
Workshop
Maurice de Beijer
Maurice de Beijer
Calling all React developers! Join us for an immersive 4-hour workshop diving deep into React Server Components and Server Actions. Discover how these game-changing technologies are revolutionizing web development and learn how to harness their full potential to build lightning-fast, efficient applications.
Explore the world of React Server Components, seamlessly blending server-side rendering with client-side interactivity for unmatched performance and user experience. Dive into React Server Actions to see how they combine client-side interactivity with server-side logic, making it easier to develop interactive applications without traditional API constraints.
Get hands-on experience with practical exercises, real-world examples, and expert guidance on implementing these technologies into your projects. Learn essential topics such as the differences between Server and Client Components, optimizing data fetching, passing data effectively, and maximizing performance with new React hooks like useActionState, useFormStatus and useOptimistic.
Whether you're new to React or a seasoned pro, this workshop will equip you with the knowledge and tools to elevate your web development skills. Stay ahead of the curve and master the cutting-edge technology of React 19. Don't miss out - sign up now and unleash the full power of React!
Evolution of Form Management in React
React Summit US 2024React Summit US 2024
72 min
Evolution of Form Management in React
Workshop
Adrian Hajdin
Adrian Hajdin
Learn how to handle forms in React using the latest features, such as startTransition, useTransition, useOptimistic, and useActionState, with and without React 19 server actions, alongside proper validation, error handling, and best practices.The workshop will begin by demonstrating traditional form handling using useState and useEffect for client-side rendering. Gradually, we'll transition to using the latest React 19 features, including server-side forms and the newest hooks for managing form states and errors. By the end of the workshop, participants will understand how to create robust forms with proper validation and error handling.Learning GoalsLatest React 19 Hooks — useTransition, useFormStatus, useOptimistic, useActionState, useDeferredValueServer ActionsRevalidationsServer-side ValidationError handlingSecurity practices