exceptionless / Exceptionless.JavaScript

Exceptionless JavaScript client
http://exceptionless.com
Apache License 2.0
59 stars 24 forks source link

Include option to pass in fallback UI component into ExceptionlessErrorBoundary #102

Closed polluterofminds closed 3 years ago

polluterofminds commented 3 years ago

In the current implementation, the ExceptionlessErrorBoundary works really well for capturing UI-level errors in the components. However, one of the benefits of Error Boundaries in React is the ability to render a fallback component when there is a component-level error. In order to do that alongside the ExceptionlessErrorBoundary, you have to write code that looks like this:

ReactDOM.render(
  <React.StrictMode>
    <ErrorBoundary>
      <ExceptionlessErrorBoundary>
        <App />
      </ExceptionlessErrorBoundary>
    </ErrorBoundary>
  </React.StrictMode>,
  document.getElementById('root')
);

Having to create your own Error Boundary class component just to render a fallback image feels tedious and repetitive. It would be nice if the ExceptionlessErrorBoundary took an optional component prop that could be used to render a fallback. Something like this:

ReactDOM.render(
  <React.StrictMode>
      <ExceptionlessErrorBoundary fallbackComponent={ErrorUI}>
        <App />
      </ExceptionlessErrorBoundary>
  </React.StrictMode>,
  document.getElementById('root')
);
niemyjski commented 3 years ago

We could do this, but my counter argument is if you want to remove Exceptionless, now you have to create the error boundary anyways and redo the ui instead of removing two lines of code. I kinda like being transparent and single responsibility (of just capturing the errors, not doing many things), thoughts?

polluterofminds commented 3 years ago

Yeah, that's a fair argument. I don't have a super strong opinion. I just felt like it was tedious when I was setting this up and it seemed like a nice (optional) bonus for people to have.

niemyjski commented 3 years ago

Let's close this until it's requested by a few end users. If you are reading this and like this upvote and leave a comment :).