首页 > 技术文章 > React Native遇到的坑

chhom 2016-08-08 14:11 原文

错误提示

错误一:

 

出现这个问题,解决方法:打开menu,点击“Dev Settings”,然后在点击“Debug server host&port for device”,在输入框中输入:连接的电脑的IP地址:8081

 

问题二:

Invariant Violation:Applicaction 项目名 has not been registered.This is either due to a require() error during initialization or failure to call AppRegistry.registerCommponent.

这个错误的根本原因是根目录./index.android.js中

AppRegistry.registerComponent('项目名',() => ...);

与./android/项目名/appDelegate.m中的

RCTRootView*rootView = [[RCTRootViewalloc]initWithBundleURL:jsCodeLocation

moduleName:@"项目名" launchOptions:launchOptions];

或是./android/app/src/main/java/com/项目名/MainActivity.java中的

mReactRootView.startReactApplication(mReactInstanceManager, "项目名", null);

没有保持一致,解决方法很简单。编辑成相同的参数即可。

 

 

 




推荐阅读