mirror of
https://github.com/langgenius/dify.git
synced 2026-04-26 05:35:58 +08:00
Remove verbose comments and appId reset logic since parent component remounts on appId change. Consolidate imports and use function declaration.
23 lines
596 B
TypeScript
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>
|
|
)
|
|
}
|