You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gcgj-dify-1.7.0/web/app/components/workflow/nodes/knowledge-base/hooks/use-config.ts

20 lines
520 B
TypeScript

import {
useCallback,
useRef,
} from 'react'
import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud'
import type { KnowledgeBaseNodeType } from '../types'
export const useConfig = (id: string, payload: KnowledgeBaseNodeType) => {
const {
inputs,
setInputs,
} = useNodeCrud(id, payload)
const ref = useRef(inputs)
const handleInputsChange = useCallback((newInputs: KnowledgeBaseNodeType) => {
setInputs(newInputs)
ref.current = newInputs
}, [setInputs, ref])
}