make null value checks

Co-authored-by: Roman Hotsiy <gotsijroman@gmail.com>
This commit is contained in:
Sequence Lin 2020-10-29 10:20:35 +03:00 committed by GitHub
parent 8f72da450d
commit d55df5af8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -27,8 +27,8 @@ class Json extends React.PureComponent<JsonProps> {
}
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 (

View File

@ -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(<JsonViewer data={flatData} />));
const expandButton = flatDataComponent.find('div > button[children=" Expand all "]');