-
Notifications
You must be signed in to change notification settings - Fork 257
Expand file tree
/
Copy pathindex.js
More file actions
35 lines (30 loc) · 1.1 KB
/
index.js
File metadata and controls
35 lines (30 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import Bugsnag from '@bugsnag/js'
import BugsnagPluginReact from '@bugsnag/plugin-react'
import React from 'react'
import ReactDOM from 'react-dom'
import './index.css'
import App from './App'
Bugsnag.start({
apiKey: 'YOUR_API_KEY',
plugins: [new BugsnagPluginReact(React)]
})
const ErrorBoundary = Bugsnag.getPlugin('react')
const ErrorScreen = ({ clearError }) =>
<div>
<h1>⚠️ Error ⚠️</h1>
<p><strong>Uh oh, there was an error in the component tree!</strong></p>
<p>This <code>FallbackComponent</code> prop can be used to show something useful to your users when such errors occur.</p>
<button onClick={clearError}>Reset</button>
</div>
const onError = event => {
// You can also provide an onError callback to run just on errors caught by
// the error boundary. Maybe you want to attach some of the current state from
// whatever model/store you're using (e.g redux)
console.log('about to send this event', { event })
}
ReactDOM.render(
<ErrorBoundary FallbackComponent={ErrorScreen} onError={onError}>
<App />
</ErrorBoundary>,
document.getElementById('root')
)