Reactjs v18.0 what is new?

Wandy Santana
NicaSource

--

React.js has been a fundamental part of the development of multiple web pages and applications around the world. Meta created this popular open-source library in 2013. And now, the React.js community is celebrating the arrival of the new v18.0.

React18 was officially launched in late March from its Alpha to Beta version. Some development communities have already tested this latest update, praising its new features and functions. Part of the releases of the new version releases is focused on maintaining third-party libraries by presenting never-before-seen improvements.

The option “simultaneous view” is responsible for the new React.js features and improvements that all React developers are excited about. Simultaneous views allow us to create several versions of the UI itself.

Let’s take an in-depth look at the new enhancements and features in React 18:

Introduces a New Root API

In React, the “root” is a pointer to the top-level data structure. The root is used to keep track of the representation of a tree. Having a legacy root API, is murky to users as it can be attached to the DOM element and thus accessed via the DOM node without exposing the root to users. However, it is not necessary to store the root in the DOM node is not needed.

The legacy root API had some issues. For example, to run updates, we needed to continuously pass the container to the render, even though it never changes. The addition of a new root API fixes this problem.

The best in automatic batching

Batching means grouping updates from different React states into a single render state, achieving better computational performance. In the past, only event handlers’ tasks were batched in previous versions of React. Other events, such as asynchronous state updates, were not automated tasks by default. The issue was resolved by adding automatic batch processing in React 18 when using the new root API. Now updates will be processed automatically regardless of their origin.

The new “Star transition API” to keep the app responsive

The startTransition API helps us keep our app responsive during updates or larger screen renderings. This API allows us to control the appearance of concurrent renders to improve user interactions.

This API will package heavy updates, such as “startTransition,” and will break only if more urgent ones are started. Therefore, urgent and slow updates are classified. One thing to note is that if the transition is interrupted by user actions, React will immediately discard the unfinished stale render job and simply continue rendering the latest update.

Server Side Architectural Enhancement

One of the new features of v18 is the architectural improvement of the React.js SSR representation. The SSR rendering generates HTML from the components on the server and then sends it back to the client. The page’s content may be seen before it is loaded and the JS package is run.

Conclusion

The extensive React community is already testing this new version. They have taken it upon themselves to compile a list of libraries that are compatible with React.js v18, and any developer may access it.

The React 18 updates implemented on this release are some of React’s best features. Your project will benefit from Meta’s improvements to this popular JS library. It is advisable to be cautious and test changes beforehand to avoid issues in production projects.

--

--