mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-01 06:42:26 +00:00
14 lines
573 B
TypeScript
14 lines
573 B
TypeScript
import { createContext, useContext, type ParentProps, type ValidComponent } from "solid-js"
|
|
|
|
const DiffComponentContext = createContext<ValidComponent>()
|
|
|
|
export function DiffComponentProvider(props: ParentProps<{ component: ValidComponent }>) {
|
|
return <DiffComponentContext.Provider value={props.component}>{props.children}</DiffComponentContext.Provider>
|
|
}
|
|
|
|
export function useDiffComponent() {
|
|
const component = useContext(DiffComponentContext)
|
|
if (!component) throw new Error("DiffComponentProvider must be used to provide a diff component")
|
|
return component
|
|
}
|