Fix/workflow use nodes hooks (#21822)

This commit is contained in:
zxhlyh
2025-07-02 17:48:23 +08:00
committed by GitHub
parent 3bfa9767c0
commit 68f41bbaa8
7 changed files with 74 additions and 34 deletions

View File

@@ -14,11 +14,14 @@ import BasePanel from './_base/components/workflow-panel'
const CustomNode = (props: NodeProps) => {
const nodeData = props.data
const NodeComponent = NodeComponentMap[nodeData.type]
const NodeComponent = useMemo(() => NodeComponentMap[nodeData.type], [nodeData.type])
return (
<>
<BaseNode {...props}>
<BaseNode
id={props.id}
data={props.data}
>
<NodeComponent />
</BaseNode>
</>
@@ -26,7 +29,12 @@ const CustomNode = (props: NodeProps) => {
}
CustomNode.displayName = 'CustomNode'
export const Panel = memo((props: Node) => {
export type PanelProps = {
type: Node['type']
id: Node['id']
data: Node['data']
}
export const Panel = memo((props: PanelProps) => {
const nodeClass = props.type
const nodeData = props.data
const PanelComponent = useMemo(() => {
@@ -38,7 +46,11 @@ export const Panel = memo((props: Node) => {
if (nodeClass === CUSTOM_NODE) {
return (
<BasePanel key={props.id} {...props}>
<BasePanel
key={props.id}
id={props.id}
data={props.data}
>
<PanelComponent />
</BasePanel>
)