File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ implementation. You _almost always_ want to use the version from
48
48
function RouterProvider({
49
49
router ,
50
50
flushSync : reactDomFlushSyncImpl ,
51
+ unstable_onError ,
51
52
}: RouterProviderProps ): React .ReactElement
52
53
```
53
54
@@ -63,6 +64,24 @@ You usually don't have to worry about this:
63
64
- If you are rendering in a non - DOM environment , you can import
64
65
` RouterProvider ` from ` react-router ` and ignore this prop
65
66
67
+ ### unstable_onError
68
+
69
+ An error handler function that will be called for any loader/action/render
70
+ errors that are encountered in your application. This is useful for
71
+ logging or reporting errors instead of the `ErrorBoundary` because it's not
72
+ subject to re-rendering and will only run one time per error.
73
+
74
+ The `errorInfo` parameter is passed along from
75
+ [`componentDidCatch`](https : // react.dev/reference/react/Component#componentdidcatch)
76
+ and is only present for render errors .
77
+
78
+ ` ` ` tsx
79
+ <RouterProvider unstable_onError=(error, errorInfo) => {
80
+ console.error(error, errorInfo);
81
+ reportToErrorService(error, errorInfo);
82
+ }} />
83
+ ` ` `
84
+
66
85
### router
67
86
68
87
The [` DataRouter ` ](https : // api.reactrouter.com/v7/interfaces/react_router.DataRouter.html) instance to use for navigation and data fetching.
Original file line number Diff line number Diff line change @@ -38,3 +38,21 @@ available to
38
38
[` clientAction ` ](../ ../ start / framework / route - module #clientAction )/ [` clientLoader ` ](../ ../ start / framework / route - module #clientLoader )
39
39
functions
40
40
41
+ ### unstable_onError
42
+
43
+ An error handler function that will be called for any loader/action/render
44
+ errors that are encountered in your application. This is useful for
45
+ logging or reporting errors instead of the `ErrorBoundary` because it's not
46
+ subject to re-rendering and will only run one time per error.
47
+
48
+ The ` errorInfo ` parameter is passed along from
49
+ [` componentDidCatch ` ](https :// react.dev/reference/react/Component#componentdidcatch)
50
+ and is only present for render errors .
51
+
52
+ ` ` ` tsx
53
+ <HydratedRouter unstable_onError={(error, errorInfo) => {
54
+ console.error(error, errorInfo);
55
+ reportToErrorService(error, errorInfo);
56
+ }} />
57
+ ` ` `
58
+
You can’t perform that action at this time.
0 commit comments