Skip to content
PodSubs
ShowsPeopleGuestsJobsNewsEvents
More
BlogPodCred
Menu
ShowsPeopleGuestsJobsNewsEventsBlogPodCredNetworksSign in
Join nowSign in
  • Shows
  • People
  • Jobs
  • News
  • More
    • Guests
    • Events
    • Blog
    • PodCred
    • Networks
    Join nowSign in

Code & Curiosity by Maximilian Schwarzmüller

Code & Curiosity by Maximilian Schwarzmüller artwork

React 19 Is Coming!

Feb 18, 202416 minAudio

Max analyzes the official React 19 announcement blog post and explores all the exciting features that will be included in this upcoming major React version.

Audio and video play straight from the show's own hosting. PodSubs stores and serves no media.

Transcript

From the show. Tap a time to play from there.

The React team shared an update with us, which is pretty exciting for a couple of reasons. The first reason is that it's been some time since we received at least an official update, I guess, if you define official as the React blog. That's of course not entirely true, because the React team does also communicate on other channels, for example on X, but of course also

because a lot of React development recently happened in the context of Next.js or at least was communicated in the context of Next.js, but I'll get back to that. So it's pretty exciting because the last official blog post we got on the React blog was on May the 3rd, 2023, so almost a year ago, and now on February 15th, 2024, we got another blog post, another

update and a pretty exciting one, because in this update we learn a lot about the relatively near future of React, about React version 19, which will be the next major version of React, and about some exciting features that will be included in that version. In addition, there is the announcement, I guess, of React Conf 2024, which is scheduled for May 15th and 16th this year, but of course that's not the main

thing of that blog post. Instead, in that blog post, where we learn more about React's near future, the main topic probably is the new React compiler on which the React team has been working for a while now. Now, this React compiler is called react-forget, and the idea behind this compiler is that it will take a look at your React code, essentially, and it will try to

do memoization for you. Now, what does this mean? Well, in React, as of today, without that compiler, you sometimes have to use the useMemo hook or the useCallback hook or the memo function to wrap logic or components to make sure that they don't re-render unnecessarily, because the way React works, it can actually render components and

re-evaluate components unnecessarily because it doesn't always understand if a re-evaluation cycle is necessary or not, and you therefore have to use these hooks and so on to tell it that some value didn't change in a certain component and therefore no re-evaluation of that component is needed, things like that. Now, of course, we have all these tools in React, though, so why do we need a compiler and what is it really about,

what is memoization? Well, we have to use these different tools, useMemo, useCallback, and so on, to tell React when to not render or re-evaluate a component, and this compiler, react-forget, is about doing that for us so that we don't need to use useMemo or useCallback or the memo function anymore, but that instead, with help of that compiler, React is able to

know and find out whether a component really should be re-evaluated or not, so that React gains a deeper understanding of your code, you could say, and therefore, with that compiler, as a React developer, you would have to worry less or maybe not at all about making sure that unnecessary re-evaluations are prevented. The React compiler would do that for you in that future.

And that future is not too distant because in that blog post, which the React team shared, they also mentioned that this React compiler is no longer a research project, but that it instead already powers Instagram.com in production, so this compiler is already being used on a large-scale project and it seems to work quite well, otherwise they wouldn't be announcing it here for all React developers in the near future.

Now, it's also worth noting and mentioned in this official blog post that this compiler and the existence of that compiler will not change the general React mental model, where the UI is essentially a function of your data and your state. That will not change, it's just meant to decrease the complexity of the code you have to write, or at least get rid of that

extra work you had to do regarding those unnecessary render cycles that needed to be prevented. Which of course also was not just annoying, but also a potential source for bugs and problems, so it's great if we get some help there. Now, they also mentioned in that blog post that in order for this compiler to really work well, you must make sure that the React code you write follows certain rules or best practices, and

therefore the React team recommends that if you want to make sure that you follow React's rules, you enable strict mode in your React projects and that you use React's ESLint plugin, so that you get early warnings if somewhere in your code you have code that technically works, but is not optimal, because that code then might not be handled by the compiler in the best possible way.

Though it's also worth mentioning that the compiler, as it sounds from that blog post at least, will work such that it doesn't crash if somewhere in your code you have code that can't be analyzed and optimized automatically, it just won't be able to do anything with that code instead. So it will skip compilation if it determines that it isn't safe to compile your code. So that's that React compiler and it's a

really exciting initiative and project and I can't wait to start using it and hopefully get rid of a bunch of boilerplate code in my codebase. Now that compiler isn't everything that's announced here though. In addition we also get more details about actions or server actions as most developers might know them. Though the blog post explicitly mentions that what was previously meant to be server actions, so a feature

that allows you to run code on the server after a form is submitted, now actually became actions that can be used either on the server or also on the client, so that this actions feature, which is about to be added to React, will actually simplify the process of handling form submissions in React, even if it's just a client-side React app without any backend. Now this is also interesting because this

actions feature is one of those features I mentioned about which we mostly heard in the context of Next.js, because Next.js actually introduced stable server actions with their latest version, Next.js 14, and I do teach all about that in my Next.js course for example, but it's interesting to hear and see that it's now the React team itself on their official blog that's talking about this actions

feature and that this actions feature is a feature that's not closely tied to Next.js or frameworks in general, but that instead every React developer will be able to use it, at least that client-side actions part. The server-side part will always be a bit more complex because naturally you will need a backend for that and that's exactly what a framework like Next.js or Remix gives you, but for client-side

applications, single-page applications, this client-side actions part could be really interesting. Now connected to those actions we also get some new hooks which you can also already use for example if you're using Next.js because we're getting a useFormStatus and a useFormState hook which allow us to handle form submissions and update the UI based on them and so on, and a useOptimistic hook which helps with optimistic UI

updates so that you can update the UI the user sees even before the data has been saved in a database, for example, to give the user the best possible super snappy user experience. So that's another really interesting feature and getting more help with form submissions and of course getting that tighter integration with the backend, these are really exciting developments which will allow React developers to

build even more amazing user experiences with ease. Now one problem React suffered from, at least in my opinion, is that all these new features like React server components, for example, also were developed and published on the canary branch of React. So not on the latest stable or main branch but on a special branch or channel I should say that could be used

by every React developer but not really in an easy way I would say or at least this canary branch was mainly intended to be used by framework developers which is why many of the features published through that channel were available in Next.js and were marked as stable there even though they were not marked as stable in React itself which was a bit confusing at least for me and as far as I

can tell also for many other React developers. Now that will change as it seems with the next major version or at least that next major version React 19 which is about to be released later in 2024 as it seems that version seems to bundle a lot of features that have all been stuck in this canary channel for example the use client and use server directives which

are needed for React server components and also server actions so that is a huge feature that's going to come to stable React though it is of course worth mentioning that if you plan on using some server-side integrations some back-end integrations you will still need some framework that gives you that integration because React itself is still a library for rendering user interfaces in

the end it does not give you some server-side integration out of the box you will need to set that up on your own or use such a framework nonetheless it's nice to have it all in stable React itself in the near future and we get some other features I would guess that we get the compiler though it's not explicitly mentioned here in the blog post that it will be included in the next major version but I would guess that it is but

we'll for example also get access to some new HTML elements that we can use in our code HTML elements that will allow us to easily set some head content of our site so the title or meta tags for example so that you don't need any third-party packages for that anymore but it's built into React instead we also get some new features related to asset loading so that React can help you with efficiently

loading fonts or CSS files and this will all integrate with React's suspense feature so that you can show some fallback content whilst those assets are being loaded so that can be useful we get those actions which I already mentioned they are part of that stable channel then the client and server actions and it's also really interesting that Andrew Clark team member of the React team shared

a tweet or a post I guess on X where he mentioned that by the end of 2024 we will likely never need these APIs so these React features again use memo use callback and memo because of that React compiler I mentioned forward ref which I didn't mention yet because refs will be accepted as standard props in React components so if you build a component that should accept the ref

you will no longer need to use forward ref that seems to be another feature that's coming with React 19 as it seems React lazy should be made obsolete by React server components and we'll also get another new function the use function I guess also with React 19 which can be used to access context instead of use context but which can also be used

to handle promises and build async await like React components even if you're not using React server components because at the moment with React 18 there indeed are async components so components that can be decorated with async await but we're talking about server components here so components that are rendered on the server client only components on the other hand can't use async await and that's where this use function also

seems to come in the idea with that essentially use also works a bit like await and allows you to wait for a promise and for the data that's produced by that promise in client only components which also is another nice feature and therefore React 19 really is an upcoming React version to be excited about and I can't wait to see what we can build with that version and of course it should go

without mentioning that I will keep my React course updated as soon as there is something to be updated and added and that I will try my very best to give all my students the best possible learning experience in that course.

Open the transcript file

Hosts and Guests

Nobody is credited on this episode yet.

Credit the people on this episode

Be the first to rate this episode

More episodes

All episodes
  1. We will have to accept AI-generated content

    Oct 15, 202612 minAudio

    I think we'll have to get used to (and accept) AI generated content. Not to slop though.

    • Apple Podcasts

    Credit the people on this episode

  2. Is software dead?

    Oct 13, 202612 minAudio

    There's a lot of talk about software being dead. Unsurprisingly, it's complicated.

    • Apple Podcasts

    Credit the people on this episode

  3. GPT 6 Astra - Good Beyond 3D?

    Sep 9, 20268 minAudio

    GPT 6 Astra was released. It's a good model, I have to say. Especially for 3D work it seems to be a real game changer. But due to all the hype, you may be disappointed...

    • Apple Podcasts

    Credit the people on this episode

  4. You may ignore Omarchy but not its impact

    Aug 26, 20268 minAudio

    Omarchy got a lot of hype and visibility recently. But even if you don't care or don't use it, you shouldn't ignore it.

    • Apple Podcasts

    Credit the people on this episode

  5. SvelteKit 3, Solid 2 - Do they matter anymore?

    Aug 18, 202614 minAudio

    We're not going back to the JS framework wars. BUT new frameworks and framework versions are important. For a different reason now!

    • Apple Podcasts

    Credit the people on this episode