October 13, 2018

Reactjs16 | ErrorBoundry

ReactJS 16 came with new lifecycle hooks. One of them is for error handling - componentDidCatch(). This also knows as Error Boundry.

componentDidCatch() works for render() and other life-cycle hooks. If there will be an error in the render and lifecycle method then componentDidCatch() will handle the errors.

It won't work in the event handlers. For that, you need to use the try and catch way.

Here is the code for the same:


No comments: