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

swr 在 dev 下正常。build 后则出现了 TypeError: Cannot read property 'useContext' of null #15936

Open
LengYXin opened this issue Jun 19, 2024 · 1 comment
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x

Comments

@LengYXin
Copy link
Contributor

相关平台

微信小程序

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

复现步骤

随意找个组件使用 useSWR 或者 SWRConfig 就行。
<SWRConfig
// https://swr.bootcss.com/docs/api
value={{ revalidateOnFocus: false }}
>

期望结果

执行build 后正常

实际结果

执行build后
TypeError: Cannot read property 'useContext' of null
at define.push.../../node_modules/react/cjs/react.production.min.js.exports.useContext (vendors.js?t=wechat&s=1718764236515&v=3ba68365142b07947f0be04c33d77cf3:37)
at SWRConfig (vendors.js?t=wechat&s=1718764236515&v=3ba68365142b07947f0be04c33d77cf3:635)
image
image

环境信息

Taro CLI 3.6.32 environment info:
    System:
      OS: macOS 14.5
      Shell: 5.9 - /bin/zsh
    Binaries:
      Node: 20.14.0 - ~/.nvm/versions/node/v20.14.0/bin/node
      Yarn: 1.22.22 - ~/.nvm/versions/node/v20.14.0/bin/yarn
      npm: 10.7.0 - ~/.nvm/versions/node/v20.14.0/bin/npm
    npmPackages:
      @tarojs/cli: 3.6.32 => 3.6.32 
      @tarojs/components: 3.6.32 => 3.6.32 
      @tarojs/helper: 3.6.32 => 3.6.32 
      @tarojs/plugin-framework-react: 3.6.32 => 3.6.32 
      @tarojs/plugin-html: 3.6.32 => 3.6.32 
      @tarojs/plugin-platform-alipay: 3.6.32 => 3.6.32 
      @tarojs/plugin-platform-h5: 3.6.32 => 3.6.32 
      @tarojs/plugin-platform-jd: 3.6.32 => 3.6.32 
      @tarojs/plugin-platform-qq: 3.6.32 => 3.6.32 
      @tarojs/plugin-platform-swan: 3.6.32 => 3.6.32 
      @tarojs/plugin-platform-tt: 3.6.32 => 3.6.32 
      @tarojs/plugin-platform-weapp: 3.6.32 => 3.6.32 
      @tarojs/react: 3.6.32 => 3.6.32 
      @tarojs/runtime: 3.6.32 => 3.6.32 
      @tarojs/shared: 3.6.32 => 3.6.32 
      @tarojs/taro: 3.6.32 => 3.6.32 
      @tarojs/taro-loader: 3.6.32 => 3.6.32 
      @tarojs/webpack5-runner: 3.6.32 => 3.6.32 
      babel-preset-taro: 3.6.32 => 3.6.32 
      react: ^18 => 18.3.1 
@TheKonka TheKonka added V-3 Version - 3.x F-react Framework - React T-weapp Target - 编译到微信小程序 labels Jun 19, 2024
This was referenced Jun 22, 2024
@windsome
Copy link

遇到相同问题

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
Status: Todo
Development

No branches or pull requests

3 participants