diff --git a/Libraries/LogBox/UI/LogBoxInspectorStackFrames.js b/Libraries/LogBox/UI/LogBoxInspectorStackFrames.js index 12f674f10de..552ba9dfaf4 100644 --- a/Libraries/LogBox/UI/LogBoxInspectorStackFrames.js +++ b/Libraries/LogBox/UI/LogBoxInspectorStackFrames.js @@ -54,6 +54,11 @@ function LogBoxInspectorStackFrames(props: Props): React.Node { return `Collapse ${collapsedCount} frames`; } } + + if (props.log.getAvailableStack().length === 0) { + return null; + } + return ( { it('should render stack frames with 1 frame collapsed', () => { const output = render.shallowRender( @@ -51,4 +62,12 @@ describe('LogBoxInspectorStackFrame', () => { expect(output).toMatchSnapshot(); }); + + it('should render null for empty stack frames', () => { + const output = render.shallowRender( + {}} log={logNoStackFrames} />, + ); + + expect(output).toMatchSnapshot(); + }); }); diff --git a/Libraries/LogBox/UI/__tests__/__snapshots__/LogBoxInspectorStackFrames-test.js.snap b/Libraries/LogBox/UI/__tests__/__snapshots__/LogBoxInspectorStackFrames-test.js.snap index 6796f92d8fe..a9b6036c9b3 100644 --- a/Libraries/LogBox/UI/__tests__/__snapshots__/LogBoxInspectorStackFrames-test.js.snap +++ b/Libraries/LogBox/UI/__tests__/__snapshots__/LogBoxInspectorStackFrames-test.js.snap @@ -1,5 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`LogBoxInspectorStackFrame should render null for empty stack frames 1`] = `null`; + exports[`LogBoxInspectorStackFrame should render stack frames with 1 frame collapsed 1`] = `