Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

chore: Fix HTML-Embed test errors (#3659)

Ivan Starkov310e0127bfc5
diff --git a/packages/sdk-components-react/src/html-embed.tsx b/packages/sdk-components-react/src/html-embed.tsx
index f08920db68..3a2c1d9e6a 100644
--- a/packages/sdk-components-react/src/html-embed.tsx
+++ b/packages/sdk-components-react/src/html-embed.tsx
@@ -7,6 +7,7 @@ import {
useSyncExternalStore,
useState,
type ReactNode,
+ useMemo,
} from "react";
import { mergeRefs } from "@react-aria/utils";
import { ReactSdkContext } from "@webstudio-is/react-sdk";
@@ -147,6 +148,13 @@ const ClientEmbed = (props: ChildProps) => {
const containerRef = useRef<HTMLDivElement>(null);
const executeScripts = useRef(true);
+ const html = useMemo(
+ () => ({
+ __html: code ?? "",
+ }),
+ [code]
+ );
+
useEffect(() => {
const container = containerRef.current;
@@ -160,7 +168,7 @@ const ClientEmbed = (props: ChildProps) => {
<div
{...rest}
ref={mergeRefs(innerRef, containerRef)}
- dangerouslySetInnerHTML={{ __html: code ?? "" }}
+ dangerouslySetInnerHTML={html}
/>
);
};