Fix/workflow use nodes hooks (#21822)
This commit is contained in:
@@ -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>
|
||||
)
|
||||
|
Reference in New Issue
Block a user