Files
dify/web/app/components/workflow/skill/context.tsx
yyh 28ccd42a1c refactor(skill-editor): simplify SkillEditorProvider
Remove verbose comments and appId reset logic since parent component
remounts on appId change. Consolidate imports and use function declaration.
2026-01-15 14:10:41 +08:00

23 lines
596 B
TypeScript

'use client'
import type { SkillEditorStore } from './store'
import { useRef } from 'react'
import { createSkillEditorStore, SkillEditorContext } from './store'
type SkillEditorProviderProps = {
children: React.ReactNode
}
export function SkillEditorProvider({ children }: SkillEditorProviderProps): React.ReactElement {
const storeRef = useRef<SkillEditorStore | undefined>(undefined)
if (!storeRef.current)
storeRef.current = createSkillEditorStore()
return (
<SkillEditorContext.Provider value={storeRef.current}>
{children}
</SkillEditorContext.Provider>
)
}