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

自定义tabbar中,使用useRouter会出现null #8906

Closed
liuhuapiaoyuan opened this issue Mar 15, 2021 · 1 comment
Closed

自定义tabbar中,使用useRouter会出现null #8906

liuhuapiaoyuan opened this issue Mar 15, 2021 · 1 comment
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x

Comments

@liuhuapiaoyuan
Copy link

相关平台

微信小程序

小程序基础库: 2.14.1
使用框架: React

复现步骤

自定义tabbar,然后再tabbar组件中使用useRouter来匹配当前的激活的tab。
默认首页是可以生效的,
但是一旦发生Taro.switchTab后,useRouter会出现null,导致无法匹配到正确的激活项

期望结果

希望能解决这个问题。

实际结果

useRouter执行结果为nul

环境信息

  Taro CLI 3.1.2 environment info:
    System:
      OS: Windows 10
    Binaries:
      Node: 14.15.0 - D:\software\nodejs\node.EXE
      Yarn: 1.23.0-20200306.1615 - D:\software\yarn\bin\yarn.CMD
      npm: 6.14.8 - D:\software\nodejs\npm.CMD
@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Mar 15, 2021
@Chen-jj
Copy link
Contributor

Chen-jj commented Feb 23, 2022

不建议这样做,还是推荐使用状态管理工具进行管理。

详细原因在此处有说明:#7302 (comment)

@Chen-jj Chen-jj closed this as completed Feb 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Projects
None yet
Development

No branches or pull requests

2 participants