Is React finally going to be fixed ?

Is React finally going to be fixed ?

Recently an RFC (Request for comments) pull requests has been published on on React.js GitHub repository. The RFC is titled First class support for promises and async/await and the full description can be found here.

Mainly the pull request tries to resolve a problem that React developer have suffered of for a long time, which is dealing with asynchronous data fetching and content rendering that might sometimes cause popping issues and extra boilerplate (any written text (copy) that can be reused in new contexts or applications without significant changes to the source).

RFC Pull Request for the new use( ) hook: Screenshot from 2022-10-18 22-38-36.png

The most commonly used method currently is by defining a loader (boolean) and calling the promise responsible for fetching your data inside a useEffect( ) hook. Once the data is loaded the loader is set to false and the hydrated component would be rendered. Otherwise a loading screen is rendered.

Old method of fetching data and injecting it: old.png

With the new support for async/await, there is no more need for writing boilerplate and very long code just to check if the data is undefined or even to check if the data is of correct type. You can either hydrate the component asynchronously or wrap the promise inside a new hook called use( ). The hook’s name might be subject to changing though.

New method of fetching data and injecting it: new.png

We can clearly see the difference and how easy and intuitive it is to request some data from an API.

There is no more need for loading states 🤩 the components tree when reaching the desired component just blocks and renders the fallback (in case you are wrapping your components inside of a ) until the data is there.

The future of React.js looks more and more brighter ! This is not only good for React’s developers but also for the whole Software Development community.

If you reached this far I would like to thank you 😊 and don’t forget to like the article.