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.

avoid creating components inside the component

Oleg Isonen0da6452c728d
diff --git a/apps/designer/app/routes/canvas/$projectId.tsx b/apps/designer/app/routes/canvas/$projectId.tsx
index 72cd7c38e9..ad73bcc2c5 100644
--- a/apps/designer/app/routes/canvas/$projectId.tsx
+++ b/apps/designer/app/routes/canvas/$projectId.tsx
@@ -37,13 +37,16 @@ export const loader: LoaderFunction = async ({ params }): Promise<Data> => {
return { errors: "Unexpected error", env };
};
+const Outlet = () => {
+ const data = useLoaderData<CanvasData>();
+ return <Canvas data={data} />;
+};
+
const CanvasRoute = () => {
const data = useLoaderData<Data>();
if ("errors" in data) {
return <ErrorMessage message={data.errors} />;
}
- const Outlet = () => <Canvas data={data} />;
-
return <CanvasDocument Outlet={Outlet} />;
};
diff --git a/apps/designer/app/routes/preview/$projectId.tsx b/apps/designer/app/routes/preview/$projectId.tsx
index 22fb84c525..8bbd7a7d45 100644
--- a/apps/designer/app/routes/preview/$projectId.tsx
+++ b/apps/designer/app/routes/preview/$projectId.tsx
@@ -34,13 +34,16 @@ export const loader: LoaderFunction = async ({ params }): LoaderReturnType => {
return { errors: "Unexpected error", env };
};
+const Outlet = () => {
+ const data = useLoaderData<PreviewData>();
+ return <Root data={data} />;
+};
+
const PreviewRoute = () => {
const data = useLoaderData<PreviewData | ErrorData>();
if ("errors" in data) {
return <p>{data.errors}</p>;
}
- const Outlet = () => <Root data={data} />;
-
return <CanvasDocument Outlet={Outlet} />;
};