Skip to content

RN 的 helloworld 报错 #3921

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

Closed
nicholasxuu opened this issue Jul 23, 2019 · 10 comments
Closed

RN 的 helloworld 报错 #3921

nicholasxuu opened this issue Jul 23, 2019 · 10 comments
Assignees

Comments

@nicholasxuu
Copy link

nicholasxuu commented Jul 23, 2019

问题描述
taro新建的最基础的app,rn运行时会报错。

复现步骤

  1. taro init taroDemo
    1.5. init的配置:不用ts,无css预处理,默认模板。
  2. npm run build:rn -- --watch
  3. 去taro-native-shell项目,运行react-native run-ios --simulator="iPhone X"
  4. Invariant violation, element type is invalid

image

image

期望行为
至少 helloworld 能用

报错信息

Invariant violation, element type is invalid

搜了,网上有几乎完全一样的报错信息,但是如果是类似问题,应该是taro打包造成的问题。

https://blog.csdn.net/niuba123456/article/details/82086513

系统信息

  • 操作系统: macOS 10.14.5
  • Taro 版本 1.3.10
  • Node.js 版本 8.11.3
  • 报错平台 rn
@taro-bot
Copy link

taro-bot bot commented Jul 23, 2019

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

@nicholasxuu
Copy link
Author

找到问题了。

  1. taro版本1.3.8才行,1.3.9开始都有问题,至少解决这个后也会遇到 UIManager.getViewManagerConfig is not a function的问题。(感谢这篇blog:https://juejin.im/post/5d2ec7ed6fb9a07ec56eacac)
  2. taro init出来的文件是jsx文件,rn打包后会出现我这个issue里的错误。解决方法就是:
    把src里的jsx文件改为js文件就行了。。。

@taro-bot
Copy link

taro-bot bot commented Jul 23, 2019

CC @Pines-Cheng

@Pines-Cheng
Copy link
Contributor

UIManager.getViewManagerConfig is not a function 是 expo-av 依赖的问题,已经提了 PR ,但是还没正式发版。
expo/expo#4737

@Pines-Cheng
Copy link
Contributor

1.3.9 的模板进行了重构,有点问题已经修复了,麻烦等发版本吧。

@nicholasxuu
Copy link
Author

nicholasxuu commented Jul 23, 2019

谢谢,发现用1.3.8有mobx common的bug (新版本里修好了,现在鱼和熊掌不能兼得)

https://github.com/NervJS/taro/blob/master/packages/taro-mobx-common/src/inject.js#L29-L30

@wods
Copy link

wods commented Jul 23, 2019

选择ts可以正常运行

@viewerw
Copy link

viewerw commented Aug 12, 2019

UIManager.getViewManagerConfig is not a function 是 expo-av 依赖的问题,已经提了 PR ,但是还没正式发版。
expo/expo#4737

@unimodules/react-native-adapter 已经发布3.0.0 了,react-native-unimodules 也发了新版了,taro-rn@1.3.12 里面用的还是~0.4的react-native-unimodules ,需要更新成~0.5 @Pines-Cheng

@viewerw
Copy link

viewerw commented Aug 19, 2019

UIManager.getViewManagerConfig is not a function 是 expo-av 依赖的问题,已经提了 PR ,但是还没正式发版。
expo/expo#4737

@unimodules/react-native-adapter 已经发布3.0.0 了,react-native-unimodules 也发了新版了,taro-rn@1.3.12 里面用的还是0.4的react-native-unimodules ,需要更新成0.5 @Pines-Cheng

@Pines-Cheng

@tourze
Copy link
Contributor

tourze commented Aug 19, 2019

master已经升级到0.5了,要等下个版本发布。
可以参考我的做法,直接在package.json锁死版本:

	"resolutions": {
		"react-native-unimodules": "^0.5.3",
		"expo-av": "^6.0.0",
		"expo-brightness": "^6.0.0",
		"expo-file-system": "^6.0.0",
		"expo-image-picker": "^6.0.0",
		"expo-keep-awake": "^6.0.0",
		"expo-location": "^6.0.0",
		"expo-sensors": "^6.0.0"
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants