Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

componentDidCatch example

The componentDidCatch life-cycle method is invoked when an exception is thrown in its child component hierarchy. Components which implement componentDidCatch are called Error Boundary components. These components act as catch {} blocks to capture exceptions.

The following example has 3 components
ErrorBoundaryComponent - Implements componentDidCatch, acts as a catch {} block to capture errors in child components.
ChildComponent - Actual UI component, encapsulated in ErrorBoundaryComponent
RootComponent - This is the bootstrap component which launches the application.


This post first appeared on C# Guide, please read the originial post: here

Share the post

componentDidCatch example

×

Subscribe to C# Guide

Get updates delivered right to your inbox!

Thank you for your subscription

×