datasets-context.tsx 486 B

1234567891011121314151617181920
  1. 'use client'
  2. import { createContext, useContext } from 'use-context-selector'
  3. import type { DataSet } from '@/models/datasets'
  4. export type DatasetsContextValue = {
  5. datasets: DataSet[]
  6. mutateDatasets: () => void
  7. currentDataset?: DataSet
  8. }
  9. const DatasetsContext = createContext<DatasetsContextValue>({
  10. datasets: [],
  11. mutateDatasets: () => {},
  12. currentDataset: undefined,
  13. })
  14. export const useDatasetsContext = () => useContext(DatasetsContext)
  15. export default DatasetsContext