加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

reactjs – 如何将react-native升级到最新版本

发布时间:2020-12-15 20:12:08 所属栏目:百科 来源:网络整理
导读:我正在尝试升级到react-native(react-native-0.26.2)的最新版本,所以我可以使用react-native-flux-router. 我收到此错误: chrome控制台仅显示默认错误消息. 这是我的package.json文件 "dependencies": { "@remobile/react-native-splashscreen": "^1.0.3","
我正在尝试升级到react-native(react-native-0.26.2)的最新版本,所以我可以使用react-native-flux-router.

我收到此错误:

screenshoterror

chrome控制台仅显示默认错误消息.

这是我的package.json文件

"dependencies": {
    "@remobile/react-native-splashscreen": "^1.0.3","firebase": "^3.0.3","jwt-decode": "^2.0.1","moment": "^2.12.0","node-uuid": "^1.4.7","q": "^1.4.1","react": "15.0.2","react-native": "0.26.2","react-native-action-button": "^1.1.4","react-native-android-statusbar": "^0.1.2","react-native-animatable": "^0.6.0","react-native-button": "^1.5.0","react-native-device-info": "^0.9.3","react-native-drawer": "^2.2.3","react-native-file-uploader": "0.0.2","react-native-gifted-spinner": "0.0.4","react-native-image-picker": "^0.18.17","react-native-keep-screen-on": "^1.0.3","react-native-maps": "^0.4.2","react-native-modalbox": "^1.3.3","react-native-orientation": "^1.16.0","react-native-router-flux": "^3.26.5","react-native-simple-store": "^1.0.1","react-native-vector-icons": "^2.0.2","react-timer-mixin": "^0.13.3","underscore": "^1.8.3"
  },"devDependencies": {
    "eslint": "2.10.2","eslint-plugin-react": "5.1.1","eslint-plugin-react-native": "1.1.0-beta"
  }

这是adb logcat的输出

logcat output

升级步骤:
注*为了使当前设置正常工作

“react-native”: “0.25.1”,
“react”: “0.14.5”,
“react-native-router-flux”: “3.22.23”

我不得不安装这个特定版本

“assert”: “1.3.0”

.原因是我得到了一个缓冲区异常,搜索后这就是我找到的solution to unknown module buffer

当我尝试升级时,我得到了最新版本的react-native并做出反应.然后,在看到react-native所需的警告消息后,我降级了反应版本

“react”: “15.0.2”

然后我删除了断言包.我尝试了从卸载应用程序和重新编译的所有内容,我尝试重新启动计算机和手机.我在搜索中找到的唯一一件事是search result

所以我甚至在全球范围内安装了最新版本的babel,但不确定它能做些什么.然后我还确保在所有视图中的构造函数中都有一些东西.

export default class Home extends Component {
    constructor(props) {
        super(props);
        this.state = {
            foo: 'bar'
        }
    }

我不知道接下来该做什么,因为控制台中没有有用的错误.

解决方法

使用React Native 0.26及更高版本,React本身不再与React Native捆绑在一起.此错误似乎是由propType定义引起的,其中您或第三方组件尝试使用PropTypes.object.

您需要更新有问题的组件或更改自己的组件以直接从react包访??问PropTypes,如下所示:

import React,{ Component,PropTypes } from 'react';

class SomeComponent extends Component {
  static propTypes = {
    someProp: PropTypes.object
  };
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读