React Native遇到的问题


1. http://docs.easemob.com/im/react-native/ios-app 按照环信官方文档集成React Native 的时候,如果执行命令时报“CFBundleIdentifier” Does Not Exist这个错误


于是参考官方第4步先配置Xcode。 配置完成之后运行webstorm发现出现如下:error

 Unable to resolve module react-native/Libraries/Core/Devtools/parseErrorStack from /Users/dujiepeng/Enjoy/work/webim-react-native/node_modules/reactotron-react-native/dist/index.js: Module does not exist in the module map or in these directories:
/Users/dujiepeng/Enjoy/work/webim-react-native/node_modules/react-native/Libraries/Core/Devtools

This might be related to #4968
To resolve try the following:

Clear watchman watches: watchman watch-del-all.
Delete the node_modules folder: rm -rf node_modules && npm install.
Reset packager cache: rm -fr $TMPDIR/react-* or npm start -- --reset-cache.
RCTFatal + 104
-[RCTBatchedBridge stopLoadingWithError:] + 1138
__25-[RCTBatchedBridge start]_block_invoke_2 + 65
_dispatch_call_block_and_release + 12
_dispatch_client_callout + 8
_dispatch_main_queue_callback_4CF + 1054
CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 9
__CFRunLoopRun + 2205
CFRunLoopRunSpecific + 420
GSEventRunModal + 161
UIApplicationMain + 159
main + 111
start + 1
0x0 + 1

react-native-cli: 2.0.1
react-native: 0.36.1

猜想可能问题如下:



这段代码启动了两次, 在运行webstorm之后关闭弹出来的终端,于是程序能正常跑起来

2.试了环信的demo出现问题之后,在运行之前可以运行的工程 出现这种情况


这个问题大概是因为Importing components changed, should not use require anymore, try: import metagetplus from ('meta-extractor'),问了人说"却依赖 —服务器没打开 或者程序错误",我的解决方法是按照环信文档上配置下Xcode, 也就是第一个问题解决之后,在运行之前新创建的这个项目也能正常运行了


3.Element type is invalid…:

错误描述:
Element type is invalid: expected a String(for built-in components) or a class/function(for composite components) but got:object. check the render method of ‘….’


ES5 语法 导出模块

module.exports = Page2;

ES5语法 引入模块

var NaviBar = require('./NaviBar');

ES6 导出语法

export  default class Page2 extends Component {

ES6 语法 导入模块

import NaviBar from './NaviBar';

两种语法混乱使用, 比如用ES6 导出 用ES5导入, 就可能会产生上述错误


4.错误描述:
cannot call a class as a function

这种错误一般都是手误导致的, 错误直译就是不能调用一个类作为一个函数。
这个错误一般情况下是不好找的,可以看到 错误详情第二部分指向的是ImageEquallyEnlarge.js 中的第11行,但是

错误地方一般不是第11行导致的,而产生的错误恰恰是因为这处我不小心写错了一个单词,propTypes写成了prototype

这样就导致了上面的错误。 有时候越是粗心犯的错误越是不好解决, 大家开发的时候一定要细心。

5. 

这种错误出现情况如下:

render() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>
          Welcome to React Native!
        </Text>
        <Text style={}>     //这里没有写styles.welcome或者container 从而会报错
          To get started, edit index.ios.js
        </Text>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
});

6.在github上下载的项目不能运行? 出现”RCTRootView.h” file not found 红色提示 如图

这是依赖库没有下载, 可以在项目的根目录下 输入 npm install , 或者 直接拷一份node_modules到跟目录下就可以了.  
然后在 输入 npm start. 去运行就行了!!

7.在打开一个之前可以运行什么也没改动的文件中,运行时突然报如下:


这时把终端全都关了,重新运行下,即可正常使用

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值