antvis/G6

nodeselectchange监听事件使用useState报错 #5280

paiap posted onGitHub

G6 版本

4.x

问题描述

graph.on("nodeselectchange",(e) => {......})的事件监听中,使用useState来保存是否选中了节点报错(用于antd的Modal弹窗显示),提示为:TypeError:dispatch.useId is not a function 在控制台中还有错误提示:the above occured in the dialog component;以及warning:can not perform a react state update on an unmounted component........

项目:umi+qiankun+ts+hooks

重现链接

https://g6.antv.antgroup.com/zh/examples/interaction/select/#brush

重现步骤

graph.on('nodeselectchange', (e) => { console.log(e.selectedItems, e.select); });

在该步骤中使用useState保存e.select,用于该组件中Modal弹窗的显示与关闭

预期行为

期望能够正常弹出弹窗,

平台

  • 操作系统: Windows
  • 网页浏览器: Edge
  • G6 版本: [4.8.23]

屏幕截图或视频(可选)

1001997870286992105-IMG_20231218_112520 Uploading 1001997870286996008-IMG_20231218_112559.jpg…

1001997870286993306-IMG_20231218_112532

No response


hi @paiap, welcome!

posted by github-actions[bot] over 1 year ago

Hi @paiap, Please star this repo if you find it useful! Thanks :star:! 你好 @paiap。如果该仓库对你有用,可以 star 一下,感谢你的 :star:!

posted by github-actions[bot] over 1 year ago

使用useRef不会报错但是外部无法监听到变化

posted by paiap over 1 year ago

Hi @paiap, Please star this repo if you find it useful! Thanks :star:! 你好 @paiap。如果该仓库对你有用,可以在仓库右上角 star 一下,感谢你的 :star:!

posted by github-actions[bot] over 1 year ago

Fund this Issue

$0.00
Funded

Pull requests