From 467f9a4ea75a5108c63014202dfd6ff941cc0f9c Mon Sep 17 00:00:00 2001 From: sherwinski Date: Tue, 1 Feb 2022 14:34:38 -0500 Subject: [PATCH] fix: do not access `dominant_colors` if parent object `colors` is undefined --- src/components/Dialog/Dialog.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/Dialog/Dialog.tsx b/src/components/Dialog/Dialog.tsx index 9781e038..b9d1e888 100644 --- a/src/components/Dialog/Dialog.tsx +++ b/src/components/Dialog/Dialog.tsx @@ -261,8 +261,10 @@ export default class Dialog extends Component { stringifyJsonFields = (asset: AssetProps) => { const replaceNullWithEmptyString = (_: any, value: any) => (value === null) ? "" : value; asset.attributes.custom_fields = JSON.stringify(asset.attributes.custom_fields, replaceNullWithEmptyString); - asset.attributes.colors.dominant_colors = JSON.stringify(asset.attributes.colors.dominant_colors, replaceNullWithEmptyString); asset.attributes.tags = JSON.stringify(asset.attributes.tags, replaceNullWithEmptyString); + if (asset.attributes.colors?.dominant_colors) { + asset.attributes.colors.dominant_colors = JSON.stringify(asset.attributes.colors?.dominant_colors, replaceNullWithEmptyString); + } }; /*