SelectView

This commit is contained in:
2026-08-18 10:06:18 +02:00
parent 9fcc966206
commit bb0b203275
2 changed files with 17 additions and 1 deletions
+16
View File
@@ -0,0 +1,16 @@
export type ViewProps<C> = C extends React.ComponentType<infer P> ? P : never;
export default function SelectView<
T extends Record<string, React.ComponentType<any>>,
K extends keyof T,
>({
config,
views,
}: {
config: { currentView: K; viewProps: ViewProps<T[K]> };
views: T;
}) {
const ActiveView = views[config.currentView];
return <ActiveView {...config.viewProps} />;
}