1

I have this

bugsnagClient.use(bugsnagReact, React)
const ErrorBoundary = bugsnagClient.getPlugin('react')

<ErrorBoundary FallbackComponent={ErrorFallbackComponent}>
    <AppContainer />
</ErrorBoundary>

export const ErrorFallbackComponent =  () => <div>An error has occurred</div>

however I noticed only error that I actually do bugsnagClient.notify(new Error(error.errorMessage));

I am wondering if I have to add bugsnagClient.notify(new Error(error.errorMessage)); into my error boundry and if so how?

I was looking at this but I am not sure if bugsnag code already has wrapped my code and already has these methods.

chobo2
  • 83,322
  • 195
  • 530
  • 832

1 Answers1

1

I would suggest taking a look at the latest documentation which highlights how you can create an Error Boundary.

const ErrorBoundary = Bugsnag.getPlugin('react').createErrorBoundary(React)

export default () =>
  <ErrorBoundary FallbackComponent={ErrorView}>
    <App />
  </ErrorBoundary>

class ErrorView extends React.Component {
  // This component will be displayed when an error boundary catches an error
}

Make sure you are using the React plugin when you initialize Bugsnag:

Bugsnag.start({
  apiKey: 'YOUR_API_KEY',
  plugins: [new BugsnagPluginReact()]
})
rsokz
  • 156
  • 1
  • 9