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

10 lines
276 B
TypeScript

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