πError Handling
Error Boundary: π§β Avoid unexpected blank pages on your appβ
You can use the component ErrorBoundary
to display a fallback component when a Javascript error is caught in a children of the ErrorBoundary.
Reference documentation by React
β What to do if you want to use it on your projectβ
An example of ErrorBoundary usage in client component can be found on the profile page Profile
and renders the CrashFallback
for generic errors.
- Edit the
CrashFallback
to fit your design guidelines. - Send error to your monitoring system using the
componentDidCatch
from theErrorBoundary
.
π‘ Where to useβ
You can define fallbacks at lower levels for custom error handling.
Ex: You display a graph rendered by a certain lib. If this lib does not work on some browsers you can display a fallback instead. Wrap the graph in an ErrorBoundary
and choose the fallback to use instead by passing a FallbackComponent
prop.