Skip to content

Commit

Permalink
fix: add missing id type to render props
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvxd committed Sep 22, 2023
1 parent 6e95652 commit 18753cf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/core/components/Render/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function Render({ config, data }: { config: Config; data: Data }) {
if (config.root) {
return (
<DropZoneProvider value={{ data, config, mode: "render" }}>
<config.root.render {...data.root} editMode={false}>
<config.root.render {...data.root} editMode={false} id={"puck-root"}>
<DropZone zone={rootDroppableId} />
</config.root.render>
</DropZoneProvider>
Expand Down
10 changes: 7 additions & 3 deletions packages/core/types/Config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export type Adaptor<AdaptorParams = {}> = {
) => Promise<Record<string, any>[] | null>;
};

type WithId<T> = T & {
id: string;
};

export type Field<
Props extends { [key: string]: any } = { [key: string]: any }
> = {
Expand Down Expand Up @@ -67,7 +71,7 @@ export type ComponentConfig<
ComponentProps extends DefaultComponentProps = DefaultComponentProps,
DefaultProps = ComponentProps
> = {
render: (props: ComponentProps) => ReactElement;
render: (props: WithId<ComponentProps>) => ReactElement;
defaultProps?: DefaultProps;
fields?: Fields<ComponentProps>;
};
Expand All @@ -91,9 +95,9 @@ export type Config<
type MappedItem<Props extends { [key: string]: any } = { [key: string]: any }> =
{
type: keyof Props;
props: {
props: WithId<{
[key: string]: any;
} & { id: string };
}>;
};

export type Data<
Expand Down

0 comments on commit 18753cf

Please sign in to comment.