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

小程序插件页面无法使用Taro专有 Hooks #11373

Closed
fw6 opened this issue Mar 2, 2022 · 2 comments · Fixed by #11362
Closed

小程序插件页面无法使用Taro专有 Hooks #11373

fw6 opened this issue Mar 2, 2022 · 2 comments · Fixed by #11362
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Milestone

Comments

@fw6
Copy link
Contributor

fw6 commented Mar 2, 2022

相关平台

微信小程序

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

复现步骤

  1. taro-cli新创建一个默认的小程序插件项目
  2. 选择react框架
  3. 在插件页面list.tsx里面打印Taro.useRouter等等方法,显示undefined

期望结果

Taro专有 Hooks在小程序插件页面中可以使用

实际结果

在"@tarojs/taro"未找到相关Hooks。

环境信息

Taro CLI 3.4.2 environment info:
    System:
      OS: macOS 12.2.1
      Shell: 5.8 - /bin/zsh
    Binaries:
      Node: 14.18.2 - ~/.volta/tools/image/node/14.18.2/bin/node
      Yarn: 1.22.17 - ~/.volta/tools/image/yarn/1.22.17/bin/yarn
      npm: 6.14.15 - ~/.volta/tools/image/node/14.18.2/bin/npm
    npmPackages:
      @tarojs/components: 3.4.2 => 3.4.2 
      @tarojs/mini-runner: ^3.4.2 => 3.4.2 
      @tarojs/react: 3.4.2 => 3.4.2 
      @tarojs/runtime: 3.4.2 => 3.4.2 
      @tarojs/taro: 3.4.2 => 3.4.2 
      @tarojs/webpack-runner: 3.4.2 => 3.4.2 
      babel-preset-taro: 3.4.2 => 3.4.2 
      eslint-config-taro: 3.4.2 => 3.4.2 
      react: ^17.0.2 => 17.0.2 
@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Mar 2, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2022

等待热心的小伙伴解决问题中..., 有一些相关的 issues 可能帮助到你!

Thank you so much!

@xiejesses
Copy link

遇到同样的问题,请问有解决方法吗?

Chen-jj added a commit that referenced this issue Mar 27, 2022
* fix(taro-alipay): 支付宝小程序插件配置字段缺失

支付宝小程序插件生成的plugin.json配置缺少pages

#11361

* fix(react): 修复小程序插件无法使用hooks问题

Taro专有 Hooks在小程序插件页面中可以使用

#11373

* test(ci): 更新测试结果快照

* fix: 更改代码写法,修复错误

临时修复react-devtools在插件开发模式下报错问题;PR中根据代码建议调整写法

#11438

* Revert "fix(react): 修复小程序插件无法使用hooks问题"

This reverts commit dc93f9a.

# Conflicts:
#	packages/taro-loader/src/native-component.ts

* chore: update plugin example

* fix(react): 修复小程序插件无法使用 Taro hooks 的问题,fix #11373

* fix(loader): 修复编译小程序插件时配合使用 devtools 插件会报错的问题,fix #11438

* fix: ci

Co-authored-by: chenjiajian <798095202@qq.com>
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
3 participants