Tuesday, April 10, 2018

What's new in React 16.0

React v16.0 comes with major changes in the underlying architecture, with limited changes to the pubic API so the way we write react code doesn't change much, but the internals have changed drastically.

Some of the key new features introduces in React 16 are fragments, error boundaries, portals, improvements to server side rendering and reduced library file size.


Fragments allows us to return multiple elements/components from a react component without having to wrap them in a <div> or <span>.


Error boundaries provide us better error handling in react components. Prior to react v16.0 if a component throws an exception then the entire application will crash and the only way to recover is to refresh the page. Error boundaries allows us to catch any exception in the component tree below and display a custom fallback UI. Error boundaries can be defined using a special life-cycle method componentDidCatch().

Portals allows us to load a child components in any DOM node regardless of its location in the page/application, even if the DOM node is not under the hierarchy of the current component. Prior to this a child component can only load one of the DOM nodes which fall under hierarchy of the current component.

React 16 improves the speed of server side rendering. React 16 provides a new hydrate() method to render components which are processed in the server side. React 16 improves server side rendering speed by up-to 3 times compared to React 15.

Search Flipkart Products:
Flipkart.com

No comments: