Skip to main content

πŸ’ƒ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 the ErrorBoundary.

πŸ’‘ 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.