Web Development

Update's In React 16

NSDBytes Team
•March 16, 2020•8 min read
Share
Back to Blog

Update’s In React 16

React 16 was arguably the most significant release in the history of the popular JavaScript library. While newer versions have introduced hooks (React 16.8) and concurrent mode (React 18), React 16 fundamentally changed the underlying architecture of how React processes updates and renders components to the DOM.

With React v16.0, Facebook’s engineering team completely rewrote the internal engine of React—a project known as React Fiber—while successfully keeping the public API essentially identical to React 15. This backward compatibility, combined with massive performance improvements and long-requested features, solidified React’s position as the dominant tool for modern frontend web development.

In this deep dive, we will explore the major architectural changes introduced in React 16, how they solved long-standing bottlenecks, and how they laid the groundwork for the modern React ecosystem we use today.


1. The Core Architecture: Enter React Fiber

Prior to React 16, React used a synchronous rendering algorithm (often referred to as “Stack Reconciler”). When React processed an update, it would recursively process the entire component tree from top to bottom. Because JavaScript is single-threaded, if a component tree was deeply nested or required heavy computation, the main thread would be blocked. This resulted in dropped frames, stuttering animations, and unresponsive user interfaces.

React Fiber changed everything.

Fiber is a complete rewrite of React’s core reconciliation algorithm. Its primary goal is to enable incremental rendering. Instead of processing the entire component tree in one continuous block, Fiber breaks the rendering work into small chunks (or “fibers”).

This allows React to:

  • Pause rendering work to let the browser handle high-priority events (like user typing or animations).
  • Resume rendering where it left off.
  • Abort rendering work if it is no longer needed.
  • Prioritize different types of updates (e.g., an animation update is higher priority than fetching data in the background).

While the initial release of React 16 didn’t expose all the asynchronous capabilities of Fiber immediately, the architecture paved the way for React Suspense, Concurrent Mode, and smooth, jank-free rendering in complex custom web applications.

2. Error Boundaries: Preventing App Crashes

In React 15 and earlier, a JavaScript error inside a component’s render method or lifecycle hooks would corrupt React’s internal state. This often led to the “White Screen of Death” where the entire application would unmount and crash, leaving the user confused and frustrated.

React 16 introduced Error Boundaries.

Error boundaries are React components that catch JavaScript errors anywhere in their child component tree, log those errors, and display a fallback UI instead of crashing the whole component tree.

To create an error boundary, a class component must define either (or both) of the following lifecycle methods:

  • static getDerivedStateFromError(error): Used to render a fallback UI after an error has been thrown.
  • componentDidCatch(error, errorInfo): Used to log error information (e.g., sending the error trace to a service like Sentry or LogRocket).

By strategically placing error boundaries around major UI sections (like a sidebar, a navigation menu, or a widget), developers can isolate failures. If a specific widget crashes, the rest of the application remains fully functional, drastically improving the user experience.

3. Fragments and Strings: Cleaner DOM Structures

One of the most common complaints prior to React 16 was the requirement that a component’s render() method could only return a single parent element. This forced developers to wrap multiple sibling elements in unnecessary <div> or <span> tags (often called “wrapper hell”). This not only bloated the DOM but broke CSS layouts like Flexbox and CSS Grid that depend on direct parent-child relationships.

React 16 solved this by allowing components to return arrays of elements and Fragments.

Instead of wrapping elements in a div, you can use <React.Fragment> or its shorthand syntax <>...</>. This allows you to group a list of children without adding extra nodes to the DOM.

Additionally, components can now return raw strings and numbers. This seemingly small feature made rendering localized text and simple labels much cleaner and more intuitive.

4. Portals: Escaping the DOM Hierarchy

Sometimes, a component needs to visually break out of its DOM container. Classic examples include modals, tooltips, dropdown menus, and hover cards. In older versions of React, managing these overlays was difficult because CSS z-index and overflow: hidden rules applied by parent containers would often clip or hide the overlay.

React 16 introduced Portals via the ReactDOM.createPortal(child, container) API.

Portals provide a first-class way to render children into a completely different part of the DOM tree (e.g., directly into document.body or a dedicated #modal-root div) while keeping the component entirely within the React component hierarchy.

Even though a portal can be anywhere in the DOM tree, it behaves like a normal React child in every other way. Context flows through it normally, and events bubble up through the React tree, not the HTML DOM tree. This makes managing complex, overlay-heavy ReactJS development significantly easier and less bug-prone.

5. Faster and Streaming Server-Side Rendering (SSR)

Server-Side Rendering (SSR) is crucial for SEO and perceived load times. React 16 completely rewrote the server renderer, making it up to 3x faster than React 15.

Furthermore, React 16 introduced support for streaming SSR. Instead of waiting for the entire application to render on the server to a single massive string before sending it to the client, renderToNodeStream allows the server to send the HTML down the wire in chunks as soon as it is generated.

This means the browser can begin parsing the HTML, downloading CSS, and rendering the “above the fold” content much faster, significantly improving the Time to First Byte (TTFB) metric.

6. Reduced File Size and MIT License

Despite adding a massive new engine (Fiber) and new features, React 16 actually resulted in a smaller file size than React 15. The core team achieved this by transitioning to the Rollup bundler and utilizing better dead-code elimination techniques. The combined size of react and react-dom in version 16.0 was 32% smaller than the previous version.

Additionally, following intense community pushback over the controversial “BSD + Patents” license, Facebook re-licensed React 16 under the standard, open-source MIT license. This move cleared the way for enterprise companies and open-source projects to adopt React without legal anxiety.


Frequently Asked Questions

What is the difference between React 16 and older versions? The biggest difference is the underlying architecture. React 16 introduced the Fiber engine, which breaks rendering work into chunks and allows for asynchronous rendering. It also introduced Fragments, Portals, and Error Boundaries, solving major developer pain points from React 15.

Do I need to rewrite my code to upgrade to React 16? No. One of the most impressive feats of React 16 was that despite a complete internal rewrite, the public API remained largely the same. Most applications could upgrade simply by bumping the version number in package.json, provided they weren’t using undocumented internal APIs.

What is an Error Boundary in React? An Error Boundary is a React component that catches JavaScript errors in its child component tree, logs those errors, and displays a fallback UI (like a friendly error message) instead of crashing the entire application.

Why are React Portals useful? Portals allow you to render a component outside of its parent DOM hierarchy. This is essential for components like modals, tooltips, and dropdowns that need to visually overlay the rest of the page without being constrained by CSS properties like overflow: hidden from their parent containers.

Is React 16 faster than React 15? Yes. The Fiber architecture makes the UI feel much smoother by not blocking the main thread during complex renders. Additionally, the server-side rendering (SSR) engine in React 16 is significantly faster and supports streaming, which improves initial page load times.


Elevate Your Web Applications with NSDBytes

Understanding the internal mechanics of frameworks like React is what separates an average application from a high-performance, enterprise-grade platform.

At NSDBytes, our specialized ReactJS development team leverages the deep architectural features of modern React—from Fiber scheduling and Portals to advanced SSR techniques—to build blazing-fast, scalable web applications. Whether you need to migrate legacy systems or build a new platform from scratch, we have the expertise to deliver.

Start your React project with NSDBytes →


Frequently Asked Questions

React Fiber rewrote the core reconciliation algorithm, enabling incremental rendering. It breaks work into small chunks, allowing React to pause and resume rendering, prioritize updates, and let the browser handle high-priority events. This prevents UI blocking and significantly improves responsiveness and user experience in complex applications.

Error boundaries in React 16 prevent entire applications from crashing due to JavaScript errors within component trees. They catch errors, log them, and display a fallback UI, isolating failures. This ensures that a single component error does not lead to a 'White Screen of Death' for the whole application, improving stability.

React 16 introduced Fragments, allowing components to return multiple elements without adding extra wrapper nodes to the DOM. This eliminated 'wrapper hell' and improved CSS layout compatibility. Components could also return raw strings and numbers, making rendering simpler and cleaner for text and labels, leading to a flatter DOM.

Use React Portals when a component needs to render outside its parent DOM hierarchy, such as for modals, tooltips, or dropdowns. Portals allow rendering children into a different DOM node while maintaining the React component tree context and event bubbling, solving common `z-index` and `overflow` issues for overlays.

Implementing streaming SSR with React 16 involves configuring server environments and integrating `renderToNodeStream`. The timeline depends on existing application complexity, server setup, and data fetching strategies. It generally requires careful setup to ensure efficient chunking and hydration, impacting initial development time and requiring thorough testing.

React 16's re-licensing to the MIT license removed previous concerns about its 'BSD + Patents' license. The MIT license is permissive, allowing broad use in commercial and open-source projects. Data privacy regulations like GDPR are separate concerns, focusing on how user data is handled by the application, not the library's license.

NSDBytes
Written by the NSDBytes Team

We are passionate about software development, AI integration, and helping businesses achieve operational excellence through modern technology.

Need something like this built?

We’ve helped 200+ companies build and scale production-grade software.

PreviousWhy Use Unity3D?Next How To Calculate Game Development Cost?