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报错 如useDidShow, useRouter 报错:React.XXX is not a function #16274

Open
haihaifgdfsgf opened this issue Aug 9, 2024 · 0 comments
Labels
F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x

Comments

@haihaifgdfsgf
Copy link

haihaifgdfsgf commented Aug 9, 2024

相关平台

H5

浏览器版本: Chrome 版本 127.0.6533.89
使用框架: React

复现步骤

在页面导入 import Taro, { useRouter } from '@tarojs/taro' 并使用后页面报错
报错信息如下:
vendors-node_modules_taro_h5_prebundle_chunk-3QMFF3V4_js.js:5724 Uncaught TypeError: React.useMemo is not a function
at Object.useRouter (vendors-node_modules_taro_h5_prebundle_chunk-3QMFF3V4_js.js:5724:93)
at Component (index.tsx:17:1)
at renderWithHooks (vendors-node_modules_taro_h5_prebundle_chunk-PBG56SMD_js.js:12338:36)
at updateFunctionComponent (vendors-node_modules_taro_h5_prebundle_chunk-PBG56SMD_js.js:14761:40)
at updateSimpleMemoComponent (vendors-node_modules_taro_h5_prebundle_chunk-PBG56SMD_js.js:14647:28)
at updateMemoComponent (vendors-node_modules_taro_h5_prebundle_chunk-PBG56SMD_js.js:14572:36)
at beginWork (vendors-node_modules_taro_h5_prebundle_chunk-PBG56SMD_js.js:16128:40)
at HTMLUnknownElement.callCallback2 (vendors-node_modules_taro_h5_prebundle_chunk-PBG56SMD_js.js:3812:38)
at Object.invokeGuardedCallbackDev (vendors-node_modules_taro_h5_prebundle_chunk-PBG56SMD_js.js:3836:38)
at invokeGuardedCallback (vendors-node_modules_taro_h5_prebundle_chunk-PBG56SMD_js.js:3870:49)

期望结果

正常能使用taro中hook

实际结果

从taro中导出的hook都不能使用,都报相对应的错React.XXX is not a function

环境信息

👽 Taro v3.6.20


  Taro CLI 3.6.20 environment info:
    System:
      OS: Windows 10 10.0.19044
    Binaries:
      Node: 16.20.2 - D:\nodejs\node.EXE
      Yarn: 1.22.22 - D:\nodejs\yarn.CMD
      npm: 8.19.4 - D:\nodejs\npm.CMD
    npmPackages:
      @tarojs/cli: 3.6.20 => 3.6.20
      @tarojs/components: 3.6.20 => 3.6.20
      @tarojs/helper: 3.6.20 => 3.6.20
      @tarojs/plugin-framework-react: 3.6.20 => 3.6.20
      @tarojs/plugin-platform-alipay: 3.6.20 => 3.6.20
      @tarojs/plugin-platform-h5: 3.6.20 => 3.6.20
      @tarojs/plugin-platform-jd: 3.6.20 => 3.6.20
      @tarojs/plugin-platform-qq: 3.6.20 => 3.6.20
      @tarojs/plugin-platform-swan: 3.6.20 => 3.6.20
      @tarojs/plugin-platform-tt: 3.6.20 => 3.6.20
      @tarojs/plugin-platform-weapp: 3.6.20 => 3.6.20
      @tarojs/react: 3.6.20 => 3.6.20
      @tarojs/runtime: 3.6.20 => 3.6.20
      @tarojs/shared: 3.6.20 => 3.6.20
      @tarojs/taro: 3.6.20 => 3.6.20
      @tarojs/webpack5-runner: 3.6.20 => 3.6.20
      babel-preset-taro: 3.6.20 => 3.6.20
      eslint-config-taro: 3.6.20 => 3.6.20
      react: 18.2.0 => 18.2.0
@taro-bot2 taro-bot2 bot added F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x labels Aug 9, 2024
@github-project-automation github-project-automation bot moved this to Padding in H5 Aug 9, 2024
This was referenced Aug 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x
Projects
Status: Padding
Development

No branches or pull requests

1 participant