美文网首页
react native 报错汇集

react native 报错汇集

作者: 小时候丶_2e0a | 来源:发表于2020-01-10 15:57 被阅读0次

react-native 版本问题

搭建react native开发环境,最正确的肯定是官方文档,按照现在0.61版本的文档开说,node 版本不得低于10.0.0。 由于之前项目用过的都是0.55.3的版本,现在换为0.61肯定会有一系列其他改动。


Could not find iPhone 6 simulator

xcode10.~版本基本不存在次问题,

xcode 11.0 - 11.3

进入项目工程目录下(找到这个findMatchingSimulator.js 并修改)

/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js

```

/* 修改 simulators 的判断*/if(!version.startsWith('iOS')&&!version.startsWith('tvOS')){continue;}/*修改成如下*/if(!version.includes('iOS')){continue;}

```

xcode 11.3及以上

```

/* 修改 simulators 的判断*/if (!version.startsWith('iOS') && !version.startsWith('tvOS'))/*修改成如下*/if (!version.startsWith('com.apple.CoreSimulator.SimRuntime.iOS') && !version.startsWith('com.apple.CoreSimulator.SimRuntime.tvOS'))

/* 修改 simulators 的判断*/simulator.availability !== '(available)')/*修改成如下*/simulator.isAvailable !== true

```

参考1 https://www.jianshu.com/p/1df787ab33e6

参考2 https://www.jianshu.com/p/9f815533efb8

xcode11报错,解决方案:

路径: 项目/node_modules/react-native/React/Base/RCTModuleMethod.mm. (或者.m)文件

找到 static BOOL RCTParseUnused 这个方法

替换成

```

static BOOL RCTParseUnused(const char **input)

{

  return RCTReadString(input, "__unused") || RCTReadString(input, "__attribute__((__unused__))") || RCTReadString(input, "__attribute__((unused))");

}

```

简单讲,就是一个依赖下载不下来。

cd ~/.rncache

有4个文件

third-part 

没有的,去网上找一下,下载丢到这个文件夹里去

参考https://www.cnblogs.com/junhuawang/p/7573681.html

React Native undefined is not an object (evaluating 'this.onPressButton.bind')

添加 @babel/plugin-transform-flow-strip-types 依赖

在babel.config.js文件中增加

{ "plugins": [ ['@babel/plugin-transform-flow-strip-types']]}

react-native-fetch-blob 最后一次维护是在17年8月3号,已经没人维护升级了。

webview的替换

老版本import { webview } from 'react' ,新版本需要另行安装 react-native-webview, import { webview } from react-native-webview.

同时,webview向rn通讯由window.postMessage 变更为window.ReactNativeWebView.postMessage

html对rn向webview传递事件的监听需要分ios和android端,ios使用window.addEventListener android使用document.addEventListener

https://www.jianshu.com/p/44365ec64e4a

相关文章

网友评论

      本文标题:react native 报错汇集

      本文链接:https://www.haomeiwen.com/subject/ipxmactx.html