EntitySwitch: do not render anything in case no entity is present

Signed-off-by: Vincenzo Scamporlino <vincenzos@spotify.com>
This commit is contained in:
Vincenzo Scamporlino
2023-08-08 17:03:57 +02:00
parent 047e090636
commit 959a6bc833
@@ -77,18 +77,14 @@ export const EntitySwitch = (props: EntitySwitchProps) => {
})
.getElements()
.flatMap<SwitchCaseResult>((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 }),