You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/integrations/react.rst
+59-21Lines changed: 59 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ React
4
4
Installation
5
5
------------
6
6
7
-
Start by adding the ``raven.js`` script tag to your page. It should be loaded as early as possible.
7
+
Start by adding the ``raven.js`` script tag to your page. It should be loaded as early as possible, before your main javascript bundle.
8
8
9
9
.. sourcecode:: html
10
10
@@ -24,30 +24,68 @@ At this point, Raven is ready to capture any uncaught exception.
24
24
25
25
Expanded Usage
26
26
--------------
27
-
28
-
It's likely you'll end up in situations where you want to gracefully
29
-
handle errors. A good pattern for this would be to setup a logError helper:
27
+
If you're using React 16 or above, `Error Boundaries <https://reactjs.org/blog/2017/07/26/error-handling-in-react-16.html>`_
28
+
are an important tool for defining the behavior of your application in the face of errors. Be sure to send errors they catch to
29
+
Sentry using ``Raven.captureException``, and optionally this is also a great opportunity to surface `User Feedback <https://docs.sentry.io/learn/user-feedback/>`_
30
30
31
31
.. code-block:: javascript
32
32
33
-
functionlogException(ex, context) {
34
-
Raven.captureException(ex, {
35
-
extra: context
36
-
});
37
-
/*eslint no-console:0*/
38
-
window.console&&console.error&&console.error(ex);
39
-
}
40
-
41
-
Now in your components (or anywhere else), you can fail gracefully:
If you're using `Redux Saga <https://github.com/redux-saga/redux-saga>`_ be
88
+
aware that it does not bubble errors up to the browsers uncaught exception handler.
89
+
90
+
You may specify an error handler that captures saga exceptions by passing an ``onError`` function to the ``createSagaMiddleware`` options, and call ``Raven.captureException`` inside that callback.
91
+
See the `Redux Saga documentation <https://redux-saga.js.org/docs/api/#createsagamiddlewareoptions>`_ for more details.
0 commit comments