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

初始化 React Native 模板后,运行白页TypeError: undefined is not an object (evaluating 'this.__callReactNativeMicrotasks #11760

Closed
zhiqingchen opened this issue May 5, 2022 · 7 comments · Fixed by #11902
Labels
F-react Framework - React T-rn Target - 编译到 React Native V-3 Version - 3.x

Comments

@zhiqingchen
Copy link
Member

zhiqingchen commented May 5, 2022

相关平台

React Native

使用框架: React

复现步骤

  • taro init
  • 选择 react-native
  • yarn upgradePeerdeps

期望结果

正常运行

实际结果

image

image

D:\shouji\mya\node_modules\react-native\Libraries\Core\ExceptionsManager.js:149 TypeError: Cannot read property '__callReactNativeMicrotasks' of undefined

环境信息

👽 Taro v3.4.3


  Taro CLI 3.4.3 environment info:
    System:
      OS: macOS 12.0.1
      Shell: 5.8 - /bin/zsh
    Binaries:
      Node: 16.10.0 - /usr/local/bin/node
      Yarn: 1.22.10 - ~/.nvm/versions/node/v15.12.0/bin/yarn
      npm: 8.4.1 - ~/.nvm/versions/node/v17.5.0/bin/npm
    npmPackages:
      @tarojs/cli: 3.4.3 => 3.4.3
      @tarojs/components: 3.4.3 => 3.4.3
      @tarojs/mini-runner: 3.4.3 => 3.4.3
      @tarojs/react: 3.4.3 => 3.4.3
      @tarojs/runtime: 3.4.3 => 3.4.3
      @tarojs/taro: 3.4.3 => 3.4.3
      @tarojs/webpack-runner: 3.4.3 => 3.4.3
      babel-preset-taro: 3.4.3 => 3.4.3
      eslint-config-taro: 3.4.3 => 3.4.3
      react: ^17.0.2 => 17.0.2
      react-native: ^0.67.3 => 0.67.3
@taro-bot2 taro-bot2 bot added F-react Framework - React T-rn Target - 编译到 React Native V-3 Version - 3.x labels May 5, 2022
@zhiqingchen
Copy link
Member Author

zhiqingchen commented May 5, 2022

最新版本的 @babel/[email protected] 导致。

解决方案:

在 package.json 中锁定 @babel/traverse 版本

{
  "resolutions": {
    "@babel/traverse": "7.17.9"
  }
}

解决方案2(推荐)

在 package.json 中锁定 babel-plugin-minify-dead-code-elimination 版本

{
  "resolutions": {
    "babel-plugin-minify-dead-code-elimination": "0.5.2"
  }
}

记得清一下编译缓存

yarn dev:rn --reset-cache

@zhiqingchen
Copy link
Member Author

@zhiqingchen
Copy link
Member Author

image

@zhiqingchen zhiqingchen changed the title 初始化 React Native 模板后,运行白页 初始化 React Native 模板后,运行白页TypeError: undefined is not an object (evaluating 'this.__callReactNativeMicrotasks Jun 7, 2022
@zhiqingchen
Copy link
Member Author

问题原因

babel/minify#1032

@Panda-K
Copy link

Panda-K commented Sep 6, 2022

麻烦问下,我现在用Taro 3.4.12,初始化 React Native 模板后,运行白页 还是会有TypeError: undefined is not an object (evaluating 'this.__callReactNativeMicrotasks这个问题。
yarn : v1.22.17
node: v16.17.0
npm: 8.15.0

@Panda-K
Copy link

Panda-K commented Sep 6, 2022

这是配置文件:
{
"name": "GoodTest",
"version": "1.0.0",
"private": true,
"description": "this is good",
"templateInfo": {
"name": "react-native",
"typescript": false,
"css": "none"
},
"scripts": {
"build:weapp": "taro build --type weapp",
"build:swan": "taro build --type swan",
"build:alipay": "taro build --type alipay",
"build:tt": "taro build --type tt",
"build:h5": "taro build --type h5",
"build:rn": "taro build --type rn",
"build:qq": "taro build --type qq",
"build:jd": "taro build --type jd",
"build:quickapp": "taro build --type quickapp",
"dev:weapp": "npm run build:weapp -- --watch",
"dev:swan": "npm run build:swan -- --watch",
"dev:alipay": "npm run build:alipay -- --watch",
"dev:tt": "npm run build:tt -- --watch",
"dev:h5": "npm run build:h5 -- --watch",
"dev:rn": "npm run build:rn -- --watch --qr",
"dev:qq": "npm run build:qq -- --watch",
"dev:jd": "npm run build:jd -- --watch",
"dev:quickapp": "npm run build:quickapp -- --watch",
"android": "react-native run-android --no-packager",
"ios": "react-native run-ios --no-packager",
"start": "npm run dev:rn --",
"podInstall": "pod-install",
"upgradePeerdeps": "install-peerdeps @tarojs/[email protected] -o -Y && install-peerdeps @tarojs/[email protected] -o -Y && install-peerdeps @tarojs/[email protected] -o -Y && pod-install"
},
"browserslist": [
"last 3 versions",
"Android >= 4.1",
"ios >= 8"
],
"author": "",
"dependencies": {
"@babel/runtime": "^7.7.7",
"@tarojs/components": "3.4.12",
"@tarojs/react": "3.4.12",
"@tarojs/runtime": "3.4.12",
"@tarojs/taro": "3.4.12",
"@tarojs/taro-rn": "3.4.12",
"@tarojs/plugin-framework-react": "3.4.12",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-native": "^0.67.3"
},
"devDependencies": {
"@babel/core": "^7.8.0",
"@tarojs/cli": "3.4.12",
"@tarojs/mini-runner": "3.4.12",
"@tarojs/rn-runner": "3.4.12",
"@tarojs/webpack-runner": "3.4.12",
"@types/react": "^17.0.2",
"@types/react-native": "^0.67.0",
"@types/webpack-env": "^1.13.6",
"babel-preset-taro": "3.4.12",
"eslint": "^8.12.0",
"eslint-config-taro": "3.4.12",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-react": "^7.8.2",
"eslint-plugin-react-hooks": "^4.2.0",
"install-peerdeps": "^3.0.3",
"pod-install": "^0.1.23",
"stylelint": "9.3.0"
},
"resolutions": {
"babel-plugin-minify-dead-code-elimination": "0.5.2",
"@types/react": "17.0.45"
}
}

@zhiqingchen
Copy link
Member Author

  1. 确认下依赖的版本yarn why babel-plugin-minify-dead-code-elimination
  2. 清除缓存启动 yarn dev:rn --reset-cache

#11760 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-rn Target - 编译到 React Native V-3 Version - 3.x
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants