You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

use-edges-interactions-without-sync.ts 645B

123456789101112131415161718192021222324252627
  1. import { useCallback } from 'react'
  2. import produce from 'immer'
  3. import { useStoreApi } from 'reactflow'
  4. export const useEdgesInteractionsWithoutSync = () => {
  5. const store = useStoreApi()
  6. const handleEdgeCancelRunningStatus = useCallback(() => {
  7. const {
  8. edges,
  9. setEdges,
  10. } = store.getState()
  11. const newEdges = produce(edges, (draft) => {
  12. draft.forEach((edge) => {
  13. edge.data._sourceRunningStatus = undefined
  14. edge.data._targetRunningStatus = undefined
  15. edge.data._waitingRun = false
  16. })
  17. })
  18. setEdges(newEdges)
  19. }, [store])
  20. return {
  21. handleEdgeCancelRunningStatus,
  22. }
  23. }