DEV Community

React 16 Error Boundaries Let You Recover Gracefully

Jason Skowronski on February 08, 2018

React recently announced the release of version 16 with long standing feature requests including error boundaries, fragments, improved server-side ...
Collapse
 
giladpeleg profile image
Gilad Peleg

You forgot to add:

   if (this.state.errorInfo) {
         return (
           <div>Something went wrong!</div>
         );
       }
    return this.props.children;

Otherwise the inner component does not get rendered

Collapse
 
mostlyjason profile image
Jason Skowronski

Good catch! Not sure how I forgot that but I just added it.