News / Technology /

Facebook Pushes a Rewrite of React

19 Apr 2017 12:35pm, by

React developers must be used to breaking changes by now. The popular JavaScript framework has already been completely rewritten as React Native, forcing developers to rework their code to fit the new version. Now, it seems, Facebook is planning another major rewrite of the platform for the version 16 release.

At Facebook’s developer conference this week the company detailed the upcoming changes in version 15.5 of React and previewed the complete core rewrite known as React Fiber. Fiber isn’t completely new for F8, as the new core algorithm was already discussed at previous Facebook events.

In March at React Conf 2017, for example, Lin Clark from the emerging technologies group at Mozilla, detailed the changes coming to Fiber. The goal is to keep work units from jamming up threads in the application. React Fiber is able to grab a hold of processing threads, do some work, then relinquish control so that other work can be done. This is controlled through processing deadlines, which determine when React comes back up from doing work to check if it’s time to do another job.

This helps to stop single processes from monopolizing the system while doing something mundane, like drawing an interface or performing some CPU-intensive computation. The fibers come in when a process is moved in for work to be done: the fibers are the objects associated with that work and are moved in and copied into memory if they’re still applicable.

Tom Occhino, engineering manager at Facebook, said in his talk at F8 that, “It would be awesome if at the framework level we could schedule work to be done, and some rendering to be prioritized over other rendering. Not all of the work we do to render user interfaces is created equal,” said Occhino.

Occhino said that the breaking changes in React Fiber are not undertaken lightly by Facebook. “We don’t want to have to rewrite 10’s of thousands of components, and we don’t want anyone in the React community to have to go back and rewrite their apps from scratch. There’s always going to be an incremental path forward to where we want to be tomorrow,” said Occhino.

To further assuage fears, he intimated that Facebook users have been using Fiber for weeks now. “The scheduling features are currently turned off but we’re going to start enabling them over time in places where we know it’s going to provide a better experience,” said Occhino.

Occhino went on to say that React Fiber is entirely flow-typed, includes better error boundaries and has more descriptive errors and warnings, thus helping developers track down problems with less hassle.

React is not the only project being changed in a manner that breaks backward compatibility. Relay, the open source JavaScript framework Facebook for building data-driven React applications was replaced with Relay Modern on the first day of F8. Relay was built around GraphQL.

Relay Modern features a redesigned API that is less confusing to users, all while retaining the existing benefits of Relay: collocated data and view definitions, and declarative data fetching. This new framework also features performance improvements and a smaller overall package size.

React was all over F8 when it came to the conference’s main theme: various forms of reality. Augmented reality, virtual reality and mixed reality applications are the targets for React VR. This new JavaScript framework focuses on WebVR as the enabling virtual reality technology. During his keynote on Tuesday morning, Facebook founder and CEO Mark Zuckerberg stated that VR and AR were hugely important for the company going forward, and he demonstrated a number of VR and AR environments the company is working on.

Facebook officially took the banner for craziest keynote topics, this year, as on day two the company began discussing its plans for solar-powered Internet drones utilizing a newly developed millimeter wave technology to transmit up to 36Gbps over 13 kilometers. The company also discusses plans for a large tether antennae, which would dangle from a tiny helicopter, and would spread wireless Internet access with ease, and without the eyesore of a giant antenna.

The goal is to spread fast Internet access to rural areas and to eventually support things like phone calls, video chat, and ostensibly Facebook VR meetings via this new ISP service. This could take a significant amount of time to achieve, however, as the drone fleet discussed at F8 was said to be at least 10 years from deployment.


A digest of the week’s most important stories & analyses.

View / Add Comments