This is an example project showing how to use @bugsnag/js
with a React project.
This project was bootstrapped with create-react-app
.
Clone the repo and cd
into the directory of this example:
git clone [email protected]:bugsnag/bugsnag-js.git --recursive
cd bugsnag-js/examples/js/react
Take a look at…
src/index.js
to see how to setup Bugsnag once for your application and how theErrorBoundary
is usedsrc/components/BadButtons.js
to see how the errors are triggered
The project includes a Dockerfile
. If you're familiar with docker, this is the easiest way to start the example. Otherwise, skip ahead to the without docker section.
docker build -t bugsnag-js-example-react . && \
docker run -p 5000:5000 -it bugsnag-js-example-react
Note: remember to replace YOUR_API_KEY
in src/lib/bugsnag.js
with your own!
Ensure you have a version of Node.js >=4 on your machine.
npm install
npm run serve
Note: remember to replace YOUR_API_KEY
in src/index.js
with your own!