score:4

You can use error boundary. Wrap your root app inside ErrorBoundary, then you'll be able to catch error in any of the components:

<ErrorBoundary>
  <App />
</ErrorBoundary>

Here's a demo from the docs: Catching errors with error boundary


Related Query

More Query from same tag