[Feature]: Expose errorInfo
from the ErrorBoundary
#9881
Replies: 5 comments 1 reply
-
I'm having issue not able to wrap a specific component with a custom |
Beta Was this translation helpful? Give feedback.
-
Having the same issue. Would be great to have access to the componentStack |
Beta Was this translation helpful? Give feedback.
-
Duplicate proposal closed in favor of this one: #11206 |
Beta Was this translation helpful? Give feedback.
-
Yeah this is where we've landed in our discussions around this, I think we'll be looking into landing some form of API to let you log this information out/send it to Sentry, etc. - but you won't have it in the
Changes are this will basically be a client-side version of the Remix |
Beta Was this translation helpful? Give feedback.
-
We have similar request but it's more around how to surface the partial failed deferred promise errors. For example, I have the following loader: export async function loader() {
return {
promise1: new Promise((resolve, reject) => setTimeout(() => {
resolve('stuff');
}, 1000)),
promise2: new Promise((resolve, reject) => setTimeout(() => {
reject(new Response('failed', {status: 404}));
}, 3000)),
};
} It is intentional that I reject a promise with However, there is no way to know that a failed deferred promise happened unless we So maybe ... a hook to log a failed deferred promise on the server-side, with information about a deferred Promise has returned a Response - which is not a proper data format. This is just for this specific example. But it would be nice to know why a deferred promise failed instead of going silent. |
Beta Was this translation helpful? Give feedback.
-
What is the new or updated feature that you are suggesting?
A React
ErrorBoundary
componentDidCatch
exposes two things:error
, which is the thrown errorinfo
, "An object with a componentStack key containing information about which component threw the error"My understanding is that React Router implements an
ErrorBoundary
and forwards the error toerrorElement
, which can get the error by usinguseRouterError
. However, only theerror
is accessible, not theinfo
.My feature request is the following: being able to access, from within the
errorElement
, to theinfo
.I understand that
getDerivedStateFromError
does not exposeinfo
, so it might tricky to access it from theerrorElement
. In this case, anonError(error, info)
callback onRouterProvider
might also be a solution?Why should this feature be included?
Currently, we lose this
info
and, to my knowledge, there's no way to get it back, as we cannot create our own ReactErrorBoundary
, given the React Router one takes precedence. Am I wrong?Beta Was this translation helpful? Give feedback.
All reactions