refactor(web): replace useContext with use() in workflow components (#25193) (#37253)

This commit is contained in:
Rohit Gahlawat 2026-06-10 12:23:04 +05:30 committed by GitHub
parent 366e58bbbb
commit 4c347f198e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 11 additions and 11 deletions

View File

@ -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')

View File

@ -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')

View File

@ -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)
}

View File

@ -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')

View File

@ -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)!
}