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.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
another workaround for ssr
Oleg Isonenc390089f2fe5
diff --git a/apps/designer/app/canvas/shared/breakpoints.ts b/apps/designer/app/canvas/shared/breakpoints.tsindex 64e2a09e46..a4a70c7c7c 100644--- a/apps/designer/app/canvas/shared/breakpoints.ts+++ b/apps/designer/app/canvas/shared/breakpoints.ts@@ -15,6 +15,7 @@ import {export const useInitializeBreakpoints = (breakpoints: Array<Breakpoint>) => {const [, setCurrentBreakpoints] = useBreakpoints();+ // @todo ssr workaround for https://github.com/webstudio-is/webstudio-designer/issues/213const ref = useRef(false);if (ref.current === false) {ref.current = true;diff --git a/apps/designer/app/canvas/shared/instance.ts b/apps/designer/app/canvas/shared/instance.tsindex 8f23fc0be1..d7f7195046 100644--- a/apps/designer/app/canvas/shared/instance.ts+++ b/apps/designer/app/canvas/shared/instance.ts@@ -39,6 +39,7 @@ import { useMeasure } from "~/shared/dom-hooks";import { findInstanceByElement } from "~/shared/dom-utils";export const usePopulateRootInstance = (tree: Tree) => {+ // @todo ssr workaround for https://github.com/webstudio-is/webstudio-designer/issues/213const ref = useRef(false);// It is only set once when the canvas is first loaded.if (ref.current === false) {diff --git a/packages/react-sdk/src/user-props/all-user-props.ts b/packages/react-sdk/src/user-props/all-user-props.tsindex ddaef9e096..9568583062 100644--- a/packages/react-sdk/src/user-props/all-user-props.ts+++ b/packages/react-sdk/src/user-props/all-user-props.ts@@ -1,3 +1,4 @@+import { useRef } from "react";import { createValueContainer, useValue } from "react-nano-state";import type { InstanceProps, Instance } from "../db";@@ -6,16 +7,16 @@ export type AllUserProps = { [id: Instance["id"]]: InstanceProps };export const allUserPropsContainer = createValueContainer<AllUserProps>({});export const useAllUserProps = (initialUserProps?: Array<InstanceProps>) => {- if (- allUserPropsContainer.value === undefined &&- initialUserProps !== undefined- ) {+ // @todo ssr workaround for https://github.com/webstudio-is/webstudio-designer/issues/213+ const ref = useRef(false);+ if (ref.current === false && initialUserProps !== undefined) {const propsMap: AllUserProps = {};for (const props of initialUserProps) {propsMap[props.instanceId] = props;}//We don't need to trigger rerender when setting the initial valueallUserPropsContainer.value = propsMap;+ ref.current = true;}return useValue(allUserPropsContainer);};