diff --git a/src/SliceZone.tsx b/src/SliceZone.tsx index 426203f..faeafc7 100644 --- a/src/SliceZone.tsx +++ b/src/SliceZone.tsx @@ -59,7 +59,10 @@ export type SliceZoneProps = { /** A record mapping Slice types to React components. */ components: Partial< - Record> + Record< + TSlice["slice_type"], + React.ComponentType> + > >; /** The React component rendered if a component mapping from the `components` prop cannot be found. */ @@ -107,9 +110,10 @@ export const SliceZone = ({ }: SliceZoneProps): JSX.Element => { const renderedSlices = React.useMemo(() => { return slices.map((slice, index) => { - const Comp: React.ComponentType = - components[slice.slice_type as keyof typeof components] || - defaultComponent; + const Comp = (components[slice.slice_type as keyof typeof components] || + defaultComponent) as React.ComponentType< + SliceComponentProps + >; const key = JSON.stringify(slice); return (