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
4848function RouterProvider({
4949 router ,
5050 flushSync : reactDomFlushSyncImpl ,
51+ unstable_onError ,
5152}: RouterProviderProps ): React .ReactElement
5253```
5354
@@ -63,6 +64,24 @@ You usually don't have to worry about this:
6364- If you are rendering in a non - DOM environment , you can import
6465 ` RouterProvider ` from ` react-router ` and ignore this prop
6566
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+
6685### router
6786
6887The [` 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
3838[` clientAction ` ](../ ../ start / framework / route - module #clientAction )/ [` clientLoader ` ](../ ../ start / framework / route - module #clientLoader )
3939functions
4040
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