mirror of
https://github.com/langgenius/dify.git
synced 2026-02-22 19:15:47 +08:00
fix(workflow): memoize useCollaborativeWorkflow return value
Wrap the returned object in useMemo to maintain referential stability and prevent unnecessary re-renders in consumers.
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import type { Edge, Node } from '../types'
|
||||
import { useCallback } from 'react'
|
||||
import { useCallback, useMemo } from 'react'
|
||||
import { useStoreApi } from 'reactflow'
|
||||
import { collaborationManager } from '../collaboration/core/collaboration-manager'
|
||||
|
||||
@ -76,9 +76,9 @@ export const useCollaborativeWorkflow = () => {
|
||||
}
|
||||
}, [store, setNodes, setEdges])
|
||||
|
||||
return {
|
||||
return useMemo(() => ({
|
||||
getState: collaborativeStore,
|
||||
setNodes,
|
||||
setEdges,
|
||||
}
|
||||
}), [collaborativeStore, setNodes, setEdges])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user