Sitemap
Huellas Labs

Huellas Labs

We follow the trusted footprints of digital technologies to furnish promising digital solutions for your business ideas.

What’s new features introduced in ReactJs 18 ?

4 min readFeb 6, 2023

--

React is an open-source JavaScript UI library designed by Facebook, it has
gained a lot of popularity in the front-end developer community. It’s used for building interactive user interfaces and web applications quickly and efficiently with significantly less code React has launched its latest version, named React 18.React 18 has got some of the best functional dependencies designed with a vision to boost performance and make things easier for the developers. It is used to design creative APIs and render HTML files. Here is a complete list of the react 18 new features.

Press enter or click to view image in full size
React Js

Concurrent React

The concurrent react is a virtual element that eases the developers to have
multiple instances of their UI, all at the same time. React 18 introduces a new root API which provides better ergonomics for managing roots. The new root API also enables the new concurrent renderer, which allows you to opt-into concurrent features. The new root API is invoked by createRoot, which adds all of the improvements of React 18 and enables concurrent features.

Press enter or click to view image in full size
Concurrent React Example

Improvement in Automatic Batching

React has an in-built batching feature that groups all the state updates through event handlers. It saves the files from undergoing an unnecessary rendering process addition to this, React 18 has an improvised form of Batching called Automatic Batching that batches all the state updates through createRoot. The background of the updates is not necessary, and the process involves functions such as timeout and intervals, asynchronous applications, event handlers, and batch state updates.

Press enter or click to view image in full size
Press enter or click to view image in full size

New Start Transition API to Keep Your App Responsive

The developers can set a priority list based on the updates happening
frequently. The essential updates occur with direct contacts such as a click, type, press, and other functions. These updates are carried out instantly as per the developer’s requests. Transition can be used in two ways State

Get Huellas Labs’s stories in your inbox

Join Medium for free to get updates from this writer.

Transition: It starts the transition when no opening hook is available.

User transition: It is used when a hook is already available and starts the transition update. The function saves a value to keep a check at the pending state.

New Suspense SSR, Architectural Improvements

React suspense is a feature that allows the developers to keep an eye on the
rendering components till the process continues. It has a fallback feature which is then displayed. With the latest React version, this feature can be combined with the transition API. It prevents the content from being replaced and even delays the rendering schedule to reduce the loading effect.

New APIs/Hooks

React has some predefined hooks to perform a specific task as per the
developer’s request.

startTransition() — It is an API used to determine the availability of a particular transition.
useId() — is a hook that generates a unique id
useTransition() — is a hook for transition. It returns the transition state and a function to start the transition.
const [isPending, startTransition] = useTransition();

React state updates are classified into two categories:
Urgent updates — They reflect direct interaction, such as typing, clicking,
pressing, dragging, etc.
Transition updates — They transition the UI from one view to another.
useDeferredValue() — It is a hook that takes a value as a parameter and creates a duplicate copy of the same value.
useSyncExternalStore()
— is a hook recommended for reading and subscribing from external data sources (stores).
const state = useSyncExternalStore(subscribe, getSnapshot ,[getServerSnapshot]);

This method accepts three arguments:
Subscribe : It is a function to register a callback that is called whenever the
store changes.
getSnapshot : It is function that returns the current value of the store.
getServerSnapshot : It is function that returns the snapshot used during server rendering, this is an optional parameter. This method returns the value of the store, state.
useInsertionEffect() — is the hook to be used if we want it to fire before all DOM mutations. However, useInsertion Effect is intended for CSS-in-JS libraries. For normal application developers, useEffect or useLayoutEffect are used more commonly.

--

--

Huellas Labs
Huellas Labs

Written by Huellas Labs

We follow the trusted footprints of digital technologies to furnish promising digital solutions for your business ideas.