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.

use ref to check if the value is set, because of SSR

Oleg Isonena88296205be2
diff --git a/apps/designer/app/canvas/shared/instance.ts b/apps/designer/app/canvas/shared/instance.ts
index 3ac1ef6323..46c95bfd79 100644
--- a/apps/designer/app/canvas/shared/instance.ts
+++ b/apps/designer/app/canvas/shared/instance.ts
@@ -1,4 +1,4 @@
-import { useCallback, useEffect, useMemo } from "react";
+import { useCallback, useEffect, useMemo, useRef } from "react";
import ObjectId from "bson-objectid";
import {
type InstanceProps,
@@ -38,8 +38,10 @@ import {
import { useMeasure } from "~/shared/dom-hooks";
export const usePopulateRootInstance = (tree: Tree) => {
+ const ref = useRef(false);
// It is only set once when the canvas is first loaded.
- if (rootInstanceContainer.value === undefined) {
+ if (ref.current === false) {
+ ref.current = true;
rootInstanceContainer.value = tree.root;
}
};