Installation
With npm or yarn
Add the@appsignal/react and @appsignal/javascript packages to your package.json. Then, run npm install/yarn install.
You can also add these packages to your package.json on the command line:
With JSPM.io import maps
Using the JSPM.io import map generator, you can generate an import map for your application’s dependencies. Add@appsignal/javascript and @appsignal/react to the dependencies list in the generator, then add the generated import map and ES module shims to your application’s code.
With rails-importmap
Use the following command to add these packages to your Rails application’s import maps:
Usage
You must pass the AppSignal client instance as theinstance prop. In addition, the following props can optionally be passed to both the ErrorBoundary and LegacyBoundary components:
When using
tags, fallback or override, use useMemo (or useCallback for fallback and override) to memoize the values. This will prevent unnecessary re-renders.
Error Boundary
If you are using React v16 or higher, you can use theErrorBoundary component to catch errors from anywhere in the child component tree.
Legacy Boundary
TheLegacyBoundary works in almost exactly the same way as the ErrorBoundary: