mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-03 15:00:24 +00:00
fix: use diff context instead of prop drilling
This commit is contained in:
parent
123a136093
commit
9a90939ac4
9 changed files with 283 additions and 318 deletions
13
packages/ui/src/context/diff.tsx
Normal file
13
packages/ui/src/context/diff.tsx
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
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
|
||||
}
|
||||
|
|
@ -1,2 +1,3 @@
|
|||
export * from "./helper"
|
||||
export * from "./data"
|
||||
export * from "./diff"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue