dify/web/context/datasets-context.tsx

21 lines
486 B
TypeScript
Raw Normal View History

2023-05-15 08:51:32 +08:00
'use client'
import { createContext, useContext } from 'use-context-selector'
import type { DataSet } from '@/models/datasets'
export type DatasetsContextValue = {
datasets: DataSet[]
mutateDatasets: () => void
currentDataset?: DataSet
}
const DatasetsContext = createContext<DatasetsContextValue>({
datasets: [],
mutateDatasets: () => {},
currentDataset: undefined,
2023-05-15 08:51:32 +08:00
})
export const useDatasetsContext = () => useContext(DatasetsContext)
export default DatasetsContext