React Hooks as an Enabler for Concurrent mode
Tags: react, suspense, concurrentmode, reactconf
Published: 2019-11-01 20:04:09

---
title: React Hooks as an Enabler for Concurrent mode
published: true
description: How the push for functional programming will shape our future
tags: React, Suspense, ConcurrentMode, ReactConf
---

React Conf 2019 happened last week and we got some great content from all the speakers. However, I can't shake the feeling of walking away with last's years promise.

I'm not implying that the React team has been slacking or something, there was a lot of work done to prove the concept for concurrent mode and I'm glad they're taking their time to deliver something stable and proven on the real world. I had the chance to be at this (and last year's) React Conf and talk with some of the people behind the React projects and these are just my thoughts from this experience.

## The React That Was Promised

Last year, Dan Abramov delivered a memorable talk titled "Beyond React 16" about concurrent rendering aka "Time slicing"

{% youtube nLF0n9SACd4 %}

Later that same year Jared Palmer introduced us to the benefits of concurrent rendering on his talk "Moving to React Suspense"

{% youtube SCQgE4mTnjU %}

Fast Forward a full year later and this year's React Conf gives us a deep dive into Concurrent mode and how the teams at Facebook are taking advantage of it to improve initial load times and time to interactive in lower end devices through techniques like selective hydration, server-side rendering and html streaming. 

{% youtube uXEEL9mrkAQ %}


### But what exactly is Concurrent Mode? 

quoting the [Official React Docs](https://reactjs.org/docs/concurrent-mode-intro.html#what-is-concurrent-mode): 

> Concurrent Mode is a set of new features that help React apps stay responsive and gracefully adjust to the user’s device capabilities and network speed.

In simple terms, this will allow React to manage time more efficiently by  performing several tasks at the same time in a non-blocking way. So when a component isn't ready to display yet, React will do something else instead. This will enable an array of user interactions where before we would only had a frozen loading state.

With concurrent mode _fast_ devices increase in responsiveness giving a synchronous accessed data kind of feeling. In *slow* devices, the non-blocking nature of concurrent mode would provide responsiveness even with few resources, server-side rendering should take some of the load for slow devices to render the initial view, and selective hydration would increase perceived performance by prioritizing work based on user interaction heuristics.

For developers coordinating resources, data, and side-effects would become simpler, making a fluid and responsive app that scales is now easier.

## How is this related to hooks?

Last year at React Conf the Hooks API was announced, and it got a lot of hype and well deserved attention, it basically out-shined the more _"experimental"_ Suspense presentations. 

Hooks made it easier for developers to take advantage of the functional components as more than just presentational and encouraging the transition from class-based components to functional components.

Functional components enable better tree-shaking and more predictable change tracking which helped *a lot* with the developer tooling and fast refresh, also announced in this year's conference, it enables the people working on React to take advantage of functional programming concepts that create a better developer experience and increase your application's performance.

A year later hooks has taken by storm the repositories both the general public and major OSS libraries, and now that hooks has pushed functional style into the spotlight, the community is ready for the next step: Parallelism

## It's important we think about Parallelism

We're reaching the physical limits to which we can optimize chip design.
year after year Intel (as market leader) has struggled to scale down their transistors, forcing them to present new products with more cores instead. These are things that the web can take advantage of, and the React team has presented the right patterns for us developers to also benefit from that without getting into all the pitfalls of traditional "multi-threading".


The concepts that React has pushed have historically changed with the real world, and I think it is part of React's success.  


## Conclusion

Now that the landscape has changed, React is ready to give us more tools from the functional shed, with [parallelism](https://stackoverflow.com/questions/12788858/parallelism-in-functional-languages) being the focus of this year we have to consider, why is this still on the _experimental_ channel? will the third time be the charm for Concurrent mode? I'm excited to see what comes next.