From a1cf8c63b2d7b59af40f2bde05f7c2f394965dda Mon Sep 17 00:00:00 2001 From: smallstonesk <575913857@qq.com> Date: Sun, 27 Dec 2020 21:29:22 +0800 Subject: [PATCH] fix: avoid flowchart listening dblclick many times --- .../core/src/mods/settingBar/components/code/index.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/core/src/mods/settingBar/components/code/index.tsx b/packages/core/src/mods/settingBar/components/code/index.tsx index 78a3c17..13f0aaf 100644 --- a/packages/core/src/mods/settingBar/components/code/index.tsx +++ b/packages/core/src/mods/settingBar/components/code/index.tsx @@ -12,17 +12,19 @@ interface IProps { value: any; name: string; title: string; - onValueChange: (value: string) => void; flowChart: Graph; + onValueChange: (value: string) => void; } const Code: React.FC = (props) => { const { title, value, onValueChange, flowChart } = props; const [visible, setVisible] = useState(false); - flowChart.on('cell:dblclick', (args) => { - onClickEdit() - }); + useEffect(() => { + flowChart.on('node:dblclick', () => { + onClickEdit(); + }); + }, []); // events const onClickEdit = (): void => {