Showing posts with label Error boundaries. Show all posts
Showing posts with label Error boundaries. Show all posts

Tuesday, April 10, 2018

Error boundaries in React v16

React v16.0 provides better error handling, 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.

To overcome this React v16.0 introduces error boundaries. Error boundaries are special components which catch errors in its child component hierarchy and display a custom error / fallback UI. Error boundaries handle any errors in the render(), constructor or any of the component life cycle methods in its child component hierarchy.

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.