diff --git a/src/components/JsonViewer/JsonViewer.tsx b/src/components/JsonViewer/JsonViewer.tsx index 384f3cc0..ec0e00a6 100644 --- a/src/components/JsonViewer/JsonViewer.tsx +++ b/src/components/JsonViewer/JsonViewer.tsx @@ -27,8 +27,8 @@ class Json extends React.PureComponent { } renderInner = ({ renderCopyButton }) => { - const showFoldingButtons = Object.values(this.props.data).some( - (value) => typeof value === 'object', + const showFoldingButtons = this.props.data && Object.values(this.props.data).some( + (value) => typeof value === 'object' && value !== null, ); return ( diff --git a/src/components/__tests__/JsonViewer.tsx b/src/components/__tests__/JsonViewer.tsx index 32acfb75..e82c8f82 100644 --- a/src/components/__tests__/JsonViewer.tsx +++ b/src/components/__tests__/JsonViewer.tsx @@ -44,7 +44,7 @@ describe('Components', () => { }); test('Expand/Collapse buttons disappears for flat structures', () => { - const flatData = { a: 1, b: '2' }; + const flatData = { a: 1, b: '2', c: null }; const flatDataComponent = mount(withTheme()); const expandButton = flatDataComponent.find('div > button[children=" Expand all "]');