SelectView
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { useRef, useState } from "react";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import Enclave from "./app/app";
|
||||
import Enclave from "@/app/app";
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
||||
function App() {
|
||||
|
||||
@@ -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} />;
|
||||
}
|
||||
Reference in New Issue
Block a user