mirror of
https://github.com/langgenius/dify.git
synced 2026-06-11 02:31:13 +08:00
This commit is contained in:
parent
366e58bbbb
commit
4c347f198e
@ -1,6 +1,6 @@
|
||||
import type { DataSet } from '@/models/datasets'
|
||||
import { produce } from 'immer'
|
||||
import { useContext } from 'react'
|
||||
import { use } from 'react'
|
||||
import { createStore, useStore } from 'zustand'
|
||||
import { DatasetsDetailContext } from './provider'
|
||||
|
||||
@ -30,7 +30,7 @@ export const createDatasetsDetailStore = () => {
|
||||
}
|
||||
|
||||
export const useDatasetsDetailStore = <T>(selector: (state: DatasetsDetailStore) => T): T => {
|
||||
const store = useContext(DatasetsDetailContext)
|
||||
const store = use(DatasetsDetailContext)
|
||||
if (!store)
|
||||
throw new Error('Missing DatasetsDetailContext.Provider in the tree')
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ import type { SchemaTypeDefinition } from '@/service/use-common'
|
||||
import type { FlowType } from '@/types/common'
|
||||
import type { VarInInspect } from '@/types/workflow'
|
||||
import { noop } from 'es-toolkit/function'
|
||||
import { useContext } from 'react'
|
||||
import { use } from 'react'
|
||||
import {
|
||||
useStore as useZustandStore,
|
||||
} from 'zustand'
|
||||
@ -159,7 +159,7 @@ export const createHooksStore = ({
|
||||
}
|
||||
|
||||
export function useHooksStore<T>(selector: (state: Shape) => T): T {
|
||||
const store = useContext(HooksStoreContext)
|
||||
const store = use(HooksStoreContext)
|
||||
if (!store)
|
||||
throw new Error('Missing HooksStoreContext.Provider in the tree')
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { noop } from 'es-toolkit/function'
|
||||
import {
|
||||
createContext,
|
||||
useContext,
|
||||
use,
|
||||
useRef,
|
||||
} from 'react'
|
||||
import { useMitt } from '@/hooks/use-mitt'
|
||||
@ -46,5 +46,5 @@ export const MittProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
}
|
||||
|
||||
export const useMittContext = () => {
|
||||
return useContext(MittContext)
|
||||
return use(MittContext)
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import type { SchemaRoot } from '../../../types'
|
||||
import { useContext } from 'react'
|
||||
import { use } from 'react'
|
||||
import { createStore, useStore } from 'zustand'
|
||||
import { VisualEditorContext } from './context'
|
||||
|
||||
@ -26,7 +26,7 @@ export const createVisualEditorStore = () => createStore<VisualEditorStore>(set
|
||||
}))
|
||||
|
||||
export const useVisualEditorStore = <T>(selector: (state: VisualEditorStore) => T): T => {
|
||||
const store = useContext(VisualEditorContext)
|
||||
const store = use(VisualEditorContext)
|
||||
if (!store)
|
||||
throw new Error('Missing VisualEditorContext.Provider in the tree')
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { useContext } from 'react'
|
||||
import { use } from 'react'
|
||||
import {
|
||||
useStore as useZustandStore,
|
||||
} from 'zustand'
|
||||
@ -65,7 +65,7 @@ export const createNoteEditorStore = () => {
|
||||
}
|
||||
|
||||
export function useStore<T>(selector: (state: Shape) => T): T {
|
||||
const store = useContext(NoteEditorContext)
|
||||
const store = use(NoteEditorContext)
|
||||
if (!store)
|
||||
throw new Error('Missing NoteEditorContext.Provider in the tree')
|
||||
|
||||
@ -73,5 +73,5 @@ export function useStore<T>(selector: (state: Shape) => T): T {
|
||||
}
|
||||
|
||||
export const useNoteEditorStore = () => {
|
||||
return useContext(NoteEditorContext)!
|
||||
return use(NoteEditorContext)!
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user