
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
bugsnag-react
Advanced tools
A bugsnag-js plugin for React. Learn more about error reporting for React applications with Bugsnag.
This package enables you to integrate Bugsnag's error reporting with React's error boundaries. It creates and configures an <ErrorBoundary/>
component which will capture and report unhandled errors in your component tree. You either use the <ErrorBoundary/>
directly, or extend it to provide some fallback UI for your users.
Reported errors will contain useful debugging info from Reacts's internals such as the component name where the error originated, and the component stack.
You can opt to install the package from npm, using the instructions below. Alternatively you can load the plugin from our CDN via a <script/>
tag.
<script src="//d2wy8f7a9ursnm.cloudfront.net/v4/bugsnag.min.js"></script>
<script src="//d2wy8f7a9ursnm.cloudfront.net/bugsnag-plugins/v1/bugsnag-react.min.js"></script>
npm i --save bugsnag-js bugsnag-react
# or
yarn add bugsnag-js bugsnag-react
Depending on how your application is structured, usage differs slightly:
The script tag creates a global function called bugsnag__react
which needs to be passed a reference to the React
object. Ensure that React
is defined before calling this function.
<script>
window.bugsnagClient = bugsnag('API_KEY')
</script>
<script>
// in your react app…
var ErrorBoundary = bugsnagClient.use(bugsnag__react(React))
ReactDOM.render(
<ErrorBoundary>
<YourApp />
</ErrorBoundary>,
document.getElementById('app')
)
</script>
See the example for more info.
// initialize bugsnag ASAP, before other imports
import bugsnag from 'bugsnag-js'
const bugsnagClient = bugsnag('API_KEY')
import ReactDOM from 'react-dom'
import React from 'react'
import createPlugin from 'bugsnag-react'
// wrap your entire app tree in the ErrorBoundary provided
const ErrorBoundary = bugsnagClient.use(createPlugin(React))
ReactDOM.render(
<ErrorBoundary>
<YourApp />
</ErrorBoundary>,
document.getElementById('app')
)
The Bugsnag JS library and official plugins are free software released under the MIT License. See LICENSE.txt for details.
1.1.1 (2018-04-06)
FAQs
React integration for bugsnag-js
We found that bugsnag-react demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.