Is React 18 overhyped?
Tags: javascript, webdev, react
Published: 2021-11-27 09:22:24


## Is React 18 overhyped?

As a front-end developer, you must have come across articles titled as follows :

 1. What’s new in React 18?

 2. Should you learn React 18?

 3. React18: Features and updates

 4. The Complete Guide to React 18

 5. React 18 will change front-end development.

 6. Okay, 5th one was made-up…!!

All I’m trying to say, blog authors have done their best to draw awareness towards the upcoming release of React 18. My question is, “Does it worth it?”

To answer that, we will see [“What’s new in React 18?” ](https://medium.com/@therakeshpurohit/is-react-18-overhyped-4d305c26441)according to the official [plan](https://reactjs.org/blog/2021/06/08/the-plan-for-react-18.html).

 1. [**Automatic batching](https://github.com/reactwg/react-18/discussions/21) for fewer renders**

 2. **New API: [startTransition](https://github.com/reactwg/react-18/discussions/41)**

 3. [**New Suspense SSR Architecture](https://github.com/reactwg/react-18/discussions/37)**

## 1. Automatic batching

Till React 17, the only event listeners have the feature of arranging multiple **setState**.

>  A piece of code is worth a thousand words.

From React 18 it will support [inside of timeouts, promises, native event handlers or any other event will batch the same way as updates inside of React events.](https://github.com/reactwg/react-18/discussions/21#:~:text=inside%20of%20timeouts%2C%20promises%2C%20native%20event%20handlers%20or%20any%20other%20event%20will%20batch%20the%20same%20way%20as%20updates%20inside%20of%20React%20events.)

### What if I don’t want this feature?

![](https://cdn-images-1.medium.com/max/2944/1*a5yc6QuR1aiXFyNKvgwEHg.png)

## 2. startTransition

Suppose,

 1. You’ve got an input element that causes an `onChange` event

 2. The value gets updated.

 3. On value change, you fire a query for data

 4. Render the result on the screen.

It looks shallow but if we see rendering cycle and performance it may cause issues on slow environments depending on the computations going on such as animations and transitions and more interactive UI transactions.

In this case, some of us might have used **throttling** or **debouncing** or **setTimeout** but that doesn't stop the query from performing heavy UI renders.

### This is the React 18 way!

![](https://cdn-images-1.medium.com/max/2220/1*EqaPEt2-6PNXK0lKKBiJsQ.png)

Anything written inside **startTransition** will be chronicled as “non-urgent” by React. So if the user keeps changing the input value it will pick only the latest value and fire the query to get data! ( blushing while writing this line)

Quote this.
>  [Transitions lets you keep most interactions snappy even if they lead to significant UI changes. They also let you avoid wasting time rendering content that’s no longer relevant.](https://github.com/reactwg/react-18/discussions/41#:~:text=Transitions%20lets%20you%20keep%20most%20interactions%20snappy%20even%20if%20they%20lead%20to%20significant%20UI%20changes.%20They%20also%20let%20you%20avoid%20wasting%20time%20rendering%20content%20that%27s%20no%20longer%20relevant.)

**startTransition **doesn’t schedule the execution for later like setTimeout, rather it invokes immediately and synchronously.

Moreover, setTimeout doesn’t allow user interruption while startTransition allows the interruptions with the latest value only.

![Photo by [Mike van den Bos](https://unsplash.com/@mike_van_den_bos?utm_source=medium&utm_medium=referral) on [Unsplash](https://unsplash.com?utm_source=medium&utm_medium=referral)](https://cdn-images-1.medium.com/max/12096/0*VIZ4DyFigKVSbeWx)

**Loading….**

![](https://cdn-images-1.medium.com/max/2428/1*pSV1UmZvxfJRL6NUMoHmqg.png)

This is how you can optimize the user experience. Users will get a spinner only while data is being prepared. No need to write brittle asynchronous code.

## 3. Suspense SSR Architecture

Don’t misunderstand it with the [server component](https://reactjs.org/blog/2020/12/21/data-fetching-with-react-server-components.html) which is a completely different thing.

Server-Side-Rendering provides optimized hydration which leads to better SEO and indexing as well as user engagement, [FMP](https://web.dev/first-meaningful-paint/) and [FCP](https://web.dev/first-contentful-paint/).

SSR renders all HTML first and serves to the user so users can get the content, then loads JS file for interactive UI like button clicks, transitions, animation etc.

There are two new things:

 1. *Streaming HTML*

 2. *Hydration.*

Currently, it's “all or thing” there is no opt-in. In React 18 you can specifically choose which to stream first/last and which component to hydrate first/last. Totally up to you. Great, right?

## **Bonus**

**=> useId :**

To give a unique id, we rely on packages like [UUID](https://www.npmjs.com/package/uuid) (not to mention why). React has its API for that, which is globally unique. See code below.

![No need to call the function N time to get N new ids.](https://cdn-images-1.medium.com/max/2632/1*Y6yID8ivUSHarmmF4fK_6A.png)

**My opinion:**

 1. Automatic batching => Pass

 2. startTransition => Pass

 3. SSR => Pass

Yet, I believe that React 18 doesn’t merit the current hype. Not everyone running projects on React 17 are going to run ncu -u and update the react and react-dom packages.

Let me know your feedback !!