cal.pub0.org/packages/app-store/_components/DynamicComponent.tsx

18 lines
384 B
TypeScript

export function DynamicComponent<T extends Record<string, any>>(props: {
componentMap: T;
slug: string;
wrapperClassName?: string;
}) {
const { componentMap, slug, ...rest } = props;
if (!componentMap[slug]) return null;
const Component = componentMap[slug];
return (
<div className={props.wrapperClassName || ""}>
<Component {...rest} />
</div>
);
}