We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
支付宝小程序
小程序基础库: 2.0 使用框架: React
使用3.5.0 使用webpack4 选择默认模板即可重现
正常
报错
Taro CLI 3.5.0 environment info: System: OS: macOS 10.15.6 Shell: 5.7.1 - /bin/zsh Binaries: Node: 16.14.2 - /usr/local/bin/node Yarn: 1.22.10 - /usr/local/bin/yarn npm: 8.5.0 - /usr/local/bin/npm npmPackages: @tarojs/cli: 3.5.0 => 3.5.0 @tarojs/components: 3.5.0 => 3.5.0 @tarojs/helper: 3.5.0 => 3.5.0 @tarojs/mini-runner: 3.5.0 => 3.5.0 @tarojs/plugin-framework-react: 3.5.0 => 3.5.0 @tarojs/plugin-platform-alipay: 3.5.0 => 3.5.0 @tarojs/plugin-platform-jd: 3.5.0 => 3.5.0 @tarojs/plugin-platform-qq: 3.5.0 => 3.5.0 @tarojs/plugin-platform-swan: 3.5.0 => 3.5.0 @tarojs/plugin-platform-tt: 3.5.0 => 3.5.0 @tarojs/plugin-platform-weapp: 3.5.0 => 3.5.0 @tarojs/react: 3.5.0 => 3.5.0 @tarojs/router: 3.5.0 => 3.5.0 @tarojs/runtime: 3.5.0 => 3.5.0 @tarojs/shared: 3.5.0 => 3.5.0 @tarojs/taro: 3.5.0 => 3.5.0 @tarojs/taro-h5: 3.5.0 => 3.5.0 @tarojs/webpack-runner: 3.5.0 => 3.5.0 babel-preset-taro: 3.5.0 => 3.5.0 eslint-config-taro: 3.5.0 => 3.5.0 react: ^18.0.0 => 18.2.0 npmGlobalPackages: typescript: 4.7.4
The text was updated successfully, but these errors were encountered:
这里存在两个问题:
一、React 18 createRoot 异步渲染导致与小程序 onLaunch onLoad 的竞态问题,#12145 已修复
onLaunch
onLoad
但应用上述修复后还会出现第二个问题:白屏、无报错。
原因是 createRoot 使用了 setImmediate API,Webpack4 会使用 YuzuJS/setImmediate 包注入 setImmediate API。
setImmediate
YuzuJS/setImmediate
YuzuJS/setImmediate 是非常古老的一个包,关键在于它的 setTimeout 语法是这样写的:
https://github.com/YuzuJS/setImmediate/blob/f1ccbfdf09cb93aadf77c4aa749ea554503b9234/setImmediate.js#L154
它为 setTimeout 传递了第三个参数,符合 Web 规范 但支付宝小程序的 setTimeout 不支持传递第三个参数,所以导致 React18 挂载失败从而白屏。
或许我们可以写一个 webpack-loader 去处理 YuzuJS/setImmediate 的 setTimeout 写法,但目前建议开发者先自行绕过:
使用 Webpack4 开发支付宝小程序时,请使用 React17。
Sorry, something went wrong.
使用3.6.8,微信,真机调试和预览就会报错:
taro版本3.5.12,微信小程序,线上也出现了这个问题
Chen-jj
No branches or pull requests
相关平台
支付宝小程序
小程序基础库: 2.0
使用框架: React
复现步骤
使用3.5.0 使用webpack4 选择默认模板即可重现
期望结果
正常
实际结果
报错
环境信息
The text was updated successfully, but these errors were encountered: