mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-11-07 20:44:05 +09:00
use ref to check if the value is set, because of SSR
we definitely need to find a better pattern, instead of resetting on every request, we should be creating a new container on every request
This commit is contained in:
1 parent
bec39641af
commit
a88296205b
1 file changed
+4
-2
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user