diff --git a/apps/scandic-web/components/DeprecatedJsonToHtml/utils.tsx b/apps/scandic-web/components/DeprecatedJsonToHtml/utils.tsx index c87a26a96..c3fb6e3b8 100644 --- a/apps/scandic-web/components/DeprecatedJsonToHtml/utils.tsx +++ b/apps/scandic-web/components/DeprecatedJsonToHtml/utils.tsx @@ -33,13 +33,19 @@ export function nodeChildrenToHtml( embeds: EmbedByUid, fullRenderOptions: RenderOptions ): any { - return nodes.map((node, i) => { - // This function either returns a JSX element or null - return { - ...nodeToHtml(node, embeds, fullRenderOptions), - key: `child-rte-${i}`, - } - }) + return nodes + .map((node, i) => { + // This function either returns a JSX element or null + const element = nodeToHtml(node, embeds, fullRenderOptions) + if (!element) { + return null + } + return { + ...element, + key: `child-rte-${i}`, + } + }) + .filter(Boolean) } export function textNodeToHtml( diff --git a/apps/scandic-web/components/JsonToHtml/utils.tsx b/apps/scandic-web/components/JsonToHtml/utils.tsx index c7b761fa9..c3748a2fb 100644 --- a/apps/scandic-web/components/JsonToHtml/utils.tsx +++ b/apps/scandic-web/components/JsonToHtml/utils.tsx @@ -37,13 +37,19 @@ export function nodeChildrenToHtml( embeds: EmbedByUid, fullRenderOptions: RenderOptions ): any { - return nodes.map((node, i) => { - // This function either returns a JSX element or null - return { - ...nodeToHtml(node, embeds, fullRenderOptions), - key: `child-rte-${i}`, - } - }) + return nodes + .map((node, i) => { + // This function either returns a JSX element or null + const element = nodeToHtml(node, embeds, fullRenderOptions) + if (!element) { + return null + } + return { + ...element, + key: `child-rte-${i}`, + } + }) + .filter(Boolean) } export function textNodeToHtml(