-
Notifications
You must be signed in to change notification settings - Fork 47k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
componentDidCatch: document & decompose info parameter #10461
Comments
This is a new feature, to be introduced in 16 final. We'll add documentation for it soon but probably not until we release an RC. I don't expect the 2nd parameter, (the one containing |
I was not proposing to change it from an object with keys, I was proposing to add/rename keys so as to include the trace as decomposable data. // example call from framework to my component
that.componentDidCatch(err, {
text: 'Something Bad Happened\nat Foo (Bar) \n...',
componentStack: [
{component: 'Foo', createdBy: 'Bar'},
...
]
}) |
Understood! I was just offering an explanation for why we used a named-parameter for a single param 😄 and why there wasn't any docs entry for this yet (since it's only available in beta).
|
Having given this more thought, I'm thinking the following change might be nice: type Source = {
fileName: string,
lineNumber: number,
};
type StackFrame = {
name: string | null,
ownerName: string | null,
source: Source | null,
};
// Passed to the function injected via ReactFiberErrorLogger.injection.injectDialog:
// injectedFunction(capturedError: CapturedError);
type CapturedError = {
componentName: ?string,
componentStack: string,
componentStackFrames: Array<StackFrame>,
error: mixed,
errorBoundary: ?Object,
errorBoundaryFound: boolean,
errorBoundaryName: string | null,
willRetry: boolean,
};
// Passed to the componentDidCatch lifecycle hook:
// componentDidCatch(error: Error, info: ErrorInfo);
type ErrorInfo = {
componentStack: string,
componentStackFrames: Array<StackFrame>,
}; Since this proposal is backwards compatible with the beta method signature, I'm going to take a stab at it. |
Closing in favor of #10461 which has more activity. |
This issue is #10461 😄 |
Oh man. |
Some quick googling didn't show any explanation of the
info
parameter forcomponentDidCatch(error, info)
. The only key in that object that I've seen so far iscomponentStack
, which is useful, but is already composed. If I want to do some custom rendering of that information, I have to parse it.I'd love to see
info.componentStack
become a more generalinfo.text
string and then havecomponentStack
be broken down to an array of frames. Something like[{component, createdBy}]
.The text was updated successfully, but these errors were encountered: