Consider callstack as nullable

Summary:
I received an error like this while rendering:

So we should type the callstack accordingly.

Reviewed By: priteshrnandgaonkar

Differential Revision: D15921517

fbshipit-source-id: 5863c75af142f1c22d5b520db8d7c0283f401e11
This commit is contained in:
Pascal Hartig
2019-06-20 10:24:52 -07:00
committed by Facebook Github Bot
parent f40ac0617c
commit 375e313736

View File

@@ -57,7 +57,7 @@ type CrashSelectorProps = {|
export type Crash = {| export type Crash = {|
notificationID: string, notificationID: string,
callstack: string, callstack: ?string,
reason: string, reason: string,
name: string, name: string,
date: Date, date: Date,
@@ -676,15 +676,14 @@ export default class CrashReporterPlugin extends FlipperDevicePlugin<
); );
const selectedCrashID = crash.notificationID; const selectedCrashID = crash.notificationID;
const onCrashChange = id => { const onCrashChange = id => {
const newSelectedCrash = crashes.find(element => { const newSelectedCrash = crashes.find(
return element.notificationID === id; element => element.notificationID === id,
}); );
this.setState({crash: newSelectedCrash}); this.setState({crash: newSelectedCrash});
console.log('onCrashChange called', id);
}; };
const callstackString = crash.callstack;
const children = crash.callstack.split('\n').map(str => { const callstackString = crash.callstack || '';
const children = callstackString.split('\n').map(str => {
return {message: str}; return {message: str};
}); });
const crashSelector: CrashSelectorProps = { const crashSelector: CrashSelectorProps = {
@@ -699,7 +698,9 @@ export default class CrashReporterPlugin extends FlipperDevicePlugin<
<CrashReporterBar <CrashReporterBar
crashSelector={crashSelector} crashSelector={crashSelector}
openLogsCallback={() => { openLogsCallback={() => {
this.openInLogs(crash.callstack); if (crash.callstack) {
this.openInLogs(crash.callstack);
}
}} }}
/> />
) : ( ) : (