Merge pull request #19466 from weityang/fix-cannot-convert-undefined-or-null-to-object-error

fix[core-components] Fix cannot convert undefined or null to object error
This commit is contained in:
Patrik Oldsberg
2023-08-22 15:02:31 +02:00
committed by GitHub
3 changed files with 7 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/core-components': patch
---
Fixed an issue causing `StructuredMetadataTable` to crash in case metadata contained `null` values.
@@ -21,7 +21,7 @@ import { StructuredMetadataTable } from './StructuredMetadataTable';
describe('<StructuredMetadataTable />', () => {
it('renders without exploding', () => {
const metadata = { hello: 'world' };
const metadata = { hello: 'world', foo: null };
const { getByText } = render(
<StructuredMetadataTable metadata={metadata} />,
);
@@ -113,7 +113,7 @@ function toValue(
return <Fragment>{value}</Fragment>;
}
if (typeof value === 'object' && !Array.isArray(value)) {
if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
return renderMap(value, options, nested);
}