From 959a6bc83312fd6734797122a4d5b52664645d89 Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Tue, 8 Aug 2023 17:03:57 +0200 Subject: [PATCH] EntitySwitch: do not render anything in case no entity is present Signed-off-by: Vincenzo Scamporlino --- .../src/components/EntitySwitch/EntitySwitch.tsx | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/plugins/catalog/src/components/EntitySwitch/EntitySwitch.tsx b/plugins/catalog/src/components/EntitySwitch/EntitySwitch.tsx index 90de358ef9..b12495052e 100644 --- a/plugins/catalog/src/components/EntitySwitch/EntitySwitch.tsx +++ b/plugins/catalog/src/components/EntitySwitch/EntitySwitch.tsx @@ -77,18 +77,14 @@ export const EntitySwitch = (props: EntitySwitchProps) => { }) .getElements() .flatMap((element: ReactElement) => { + // If the entity is missing or there is an error, render nothing + if (!entity) { + return []; + } + const { if: condition, children: elementsChildren } = element.props as EntitySwitchCase; - // If the entity is missing or there is an error, render the default page - if (!entity) { - return [ - { - if: condition === undefined, - children: elementsChildren, - }, - ]; - } return [ { if: condition?.(entity, { apis }),