React 16 Adds Fragments
Written by Kay Ewbank   
Thursday, 05 October 2017

There's a new version of React with improvements including fragments, error boundaries, portals, and support for custom DOM attributes. 

 

 

reactlogo

 

React is Facebook’s open source JavaScript library, which lets you describe what you want to render in a declarative way using shared components and elements. For version16, React has had a complete rewrite of its internals along with other improvements to its usefulness.

The new render return types are the first improvement, with support for fragments and strings. The way the support for returning fragments works is that you can return an array of elements from a component’s render method.At the moment, you’ll need to add a key to each element to avoid the key warning, but the developers plan to add a special fragment syntax to JSX that doesn’t require keys. Support has also been added for returning strings.

Error handling has also been improved, to avoid the situation where runtime errors during rendering caused React to malfunction. The new release uses a more resilient error-handling strategy that lets you use error boundaries, components that capture errors inside their subtree and display a fallback UI in its place.

The server-side rendering has been completely rewritten in this version to be faster and to add streaming support, so you can start sending bytes to the client faster. The developers say that server rendering in React 16 is roughly three times faster than React 15. The new version also handles server-rendered HTML better once it reaches the client, reusing as much of the existing DOM as possible in cases where the content is different on the client.

Support for custom DOM attributes means that if it encounters an HTML or SVG attribute that it doesn't recognize, it will pass it through to the DOM instead of ignoring it.

One point to note about the new version is that the developers have stopped supporting React Addons. The latest version of each addon (except react-addons-perf;)  to work for the foreseeable future, but no additional updates will be published, and react-addons-perf no longer works at all in React 16. The plan is to release a new version of this tool in the future.

 

reactlogo

 

More Information

ReactJS Site

Related Articles

Facebook Re-licences React To MIT 

React 15.5 Gets Ready For Rewrite

The Programmers Guide To React 

Facebook's Relay For React Open Sourced

React 0.14 

Facebook Releases React Native

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

 

Banner


CodeRabbit Now Free In VSCode
14/05/2025

CodeRabbit, an AI-powered code review tool designed to automate the code review process is now integrated in VS Code, the first tool to deliver full-context reviews both in the IDE and in Git, he [ ... ]



AI Highlights From Google I/O 2025
22/05/2025

At Google I/O, Sundar Pichai, Demis Hassabis and others took to the stage to outline a long lineup of AI-powered products and services including Gemini 2.5,  AI Mode in Search, which is already b [ ... ]


More News

 

espbook

 

Comments




or email your comment to: comments@i-programmer.info