Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

组件ref 获取成功后 又消失 #10720

Closed
lupingW opened this issue Nov 23, 2021 · 3 comments
Closed

组件ref 获取成功后 又消失 #10720

lupingW opened this issue Nov 23, 2021 · 3 comments
Labels
bug Something isn't working F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Milestone

Comments

@lupingW
Copy link

lupingW commented Nov 23, 2021

相关平台

微信小程序

复现仓库

https://gitee.com/wangluping/ref
小程序基础库: 2.20.0
使用框架: React

复现步骤

首页 滑动地图 会打印 Ref, 此时里面是有current的. 然后点击"去下一个页面"按钮, 进入test页面, 滑动地图, 打印ref, 此时里面是有current的. 然后返回首页, 再滑动地图, 此时打印的current为null

期望结果

current为组件的this

实际结果

current为组件的null

环境信息

👽 Taro v3.3.9


  Taro CLI 3.3.9 environment info:
    System:
      OS: Windows 10
    Binaries:
      Node: 14.17.5 - D:\node\node.EXE
      npm: 6.14.14 - D:\node\npm.CMD

补充信息

将test1组件中的的this.mapId变成随机的就不会出现这个问题

@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Nov 23, 2021
@Chen-jj Chen-jj added the bug Something isn't working label Nov 28, 2021
@Chen-jj
Copy link
Contributor

Chen-jj commented Nov 28, 2021

@lupingW Taro 有一个 Map 去保存全局 dom 节点与其 id 的对应关系,但目前 Map 是全局的,没有按页面区分。因此这种情况下 Page2 dom 树的销毁会在 Map 中把 test1 组件的节点删除了。

暂时先用随机 id 绕过吧。

@Chen-jj Chen-jj added this to the 3.4.0 milestone Nov 28, 2021
@Chen-jj
Copy link
Contributor

Chen-jj commented Dec 17, 2021

duplicate #7317

@Chen-jj
Copy link
Contributor

Chen-jj commented Dec 17, 2021

Taro v3.4 修复

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Projects
None yet
Development

No branches or pull requests

2 participants