🚴‍♀️React 19 is on the way

Swati Jaiswal
3 min readMar 20, 2024

--

Hi everyone! As we know React plays a very important role now-a-days in the world of frontend, and in the upcoming month, we are getting the latest version of React. It is not just a version- believe me- it will be a game changer. On 15th of February, they have posted about their latest research on React dev blog post. I am going to explain you as much as I can about this💁‍♀.️

React Compiler

When somebody asks us how we should optimize the performance of the React application, the most common answer every React developer would recommend to minimize the re-render of application when state changes. Then, from here, the term memoization comes into picture, and to achieve this we use- useMemo, useCallback, and memo, but these are the manual way of memoization; and React team was not satisfied with this 🙅‍♀️ because as we know React is a beautiful UI library, so they wanted to beautify it more in such way that whatever re-renders, react should take care of it on its own without compromising on React’s core mental model. Keeping this in mind, they have developed a React Compiler for React which will solve this issue.

Actions

In the form, we use onSubmit event on the client side to get data from the form and we need to manage the state of the form as well. When using an action, React will manage the life cycle of the data submission for you, providing hooks like useFormStatus, and useFormState to access the current state and response of the form action. This will be possible without blocking the UI using in transition and they have added the async/await too.

They will introduce one hook called useOptimistic in which this allows you to optimistically set the final state of the data on the client side, assuming the submission is successful.

They will add some cool features that are the latest in React Canary to React as well. Like:

  • Directives
  • Document Metadata
  • Asset Loading

"use client" and "use server" are the bunder feature basically using this on top of the bundle will understand how to generate a build more accurately, let’s say, if “use client ” is written, it instructs the bundler to generate a <script> tag (like Astro Islands) and if “use server” is written, it
tells the bundler to generate a POST endpoint (like tRPC Mutations).

They will add built-in support for rendering <title>, <meta>, and metadata <link> tags anywhere in your component tree. These work the same way in all environments, including fully client-side code, SSR, and RSC.
They will integrate Suspense with the loading lifecycle of resources, such as stylesheets, fonts, and scripts so that React takes them into account to determine whether the content in elements like <style>, <link>, and <script> are ready to be displayed. They’ve also added new Resource Loading APIs like preload and preinit to provide greater control for when a resource should load and initialize.

They do talk about more things in brief which includes these:

  • Integrating Web component will become more easy. Meaning- while we are adding various libraries, for example, adding library for data table etc. Sometimes, we get some compatibility issue in some version (it works in some while breaks in other) and it helps us to implement micro frontend in easy way what I believe so.
  • We will not have to use forwardRef after this release because ref props which we are getting from it will automatically be passed in each component of react, we just need to pass the second parameter ref in the component.
  • Same goes with lazy as well because we will be getting use from react which help use to get load things asynchronously. It will help us to manage all async tasks like promises or javascript even context as well.

I hope this will add some value to your reading. If you have any suggestion and query, feel free to comment✍. And if you find this informative, please share 💌 this with your colleague and/or the React developers you know ;-) Don’t forget to give me clap👏.

Happy Reading 🙏…

For more information you can checkout👇

https://developer.mozilla.org/en-US/docs/Web/JavaScript

--

--

Swati Jaiswal
Swati Jaiswal

Written by Swati Jaiswal

Learner, Coder, JavaScript lover

No responses yet