pref: reduce the times of useNodes reRender (#28682)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Joel
2025-11-26 16:52:47 +08:00
committed by GitHub
parent d7010f582f
commit ef0e1031b0
18 changed files with 55 additions and 25 deletions

View File

@@ -4,7 +4,7 @@ import {
useRef,
} from 'react'
import { useTranslation } from 'react-i18next'
import { useEdges, useNodes, useStoreApi } from 'reactflow'
import { useEdges, useStoreApi } from 'reactflow'
import type {
CommonEdgeType,
CommonNodeType,
@@ -56,6 +56,7 @@ import {
} from '@/service/use-tools'
import { useStore as useAppStore } from '@/app/components/app/store'
import { AppModeEnum } from '@/types/app'
import useNodes from '@/app/components/workflow/store/workflow/use-nodes'
export type ChecklistItem = {
id: string
@@ -407,7 +408,7 @@ export const useChecklistBeforePublish = () => {
export const useWorkflowRunValidation = () => {
const { t } = useTranslation()
const nodes = useNodes<CommonNodeType>()
const nodes = useNodes()
const edges = useEdges<CommonEdgeType>()
const needWarningNodes = useChecklist(nodes, edges)
const { notify } = useToastContext()

View File

@@ -1,5 +1,5 @@
import { useMemo } from 'react'
import { useNodes } from 'reactflow'
import useNodes from '@/app/components/workflow/store/workflow/use-nodes'
import { useTranslation } from 'react-i18next'
import { BlockEnum, type CommonNodeType } from '../types'
import { getWorkflowEntryNode } from '../utils/workflow-entry'