Skip to content

Commit

Permalink
fix: fix renderDropZone method in editor
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvxd committed Mar 26, 2024
1 parent bf45116 commit 2c738dd
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions packages/core/components/Puck/components/Preview/index.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
import { DropZone } from "../../../DropZone";
import { rootDroppableId } from "../../../../lib/root-droppable-id";
import { useCallback, useRef } from "react";
import { ReactNode, useCallback, useRef } from "react";
import { useAppContext } from "../../context";
import AutoFrame from "@measured/auto-frame-component";
import styles from "./styles.module.css";
import { getClassNameFactory } from "../../../../lib";
import { DefaultRootProps } from "../../../../types/Config";

const getClassName = getClassNameFactory("PuckPreview", styles);

type PageProps = DefaultRootProps & { children: ReactNode };

export const Preview = ({ id = "puck-preview" }: { id?: string }) => {
const { config, dispatch, state, setStatus, iframe } = useAppContext();

const Page = useCallback(
const Page = useCallback<React.FC<PageProps>>(
(pageProps) =>
config.root?.render
? config.root?.render({ ...pageProps, editMode: true })
: pageProps.children,
config.root?.render ? (
config.root?.render({
id: "puck-root",
...pageProps,
editMode: true,
puck: { renderDropZone: DropZone },
})
) : (
<>{pageProps.children}</>
),
[config.root]
);

Expand Down

0 comments on commit 2c738dd

Please sign in to comment.