无法读取未定义的 属性 'oneOfType'

Cannot read property 'oneOfType' of undefined

我是 React Native 的新手。我想使用 'react-native-camera'。我创建了一个新项目,正确安装了包(我知道因为我已经做了三次以确保我没有做错任何事)并且它显示了这个错误 **无法读取 属性 'oneOfType'未定义的 ** 并且它在这个包 'react-native-camera' 的 index.js 中。我找不到任何解决方案。我已尝试更改 gradle 版本,gradle 包装器属性我可以更改所有内容,但此问题与 gradle 无关。这是我 App.js 中的代码。我知道代码不会产生此错误,但我是 react-native 的新手,所以也许我遗漏了一些东西。 任何建议将不胜感激

 import React, {Component} from 'react';
   import {
   Text,
   View,
  StyleSheet

 } from 'react-native';

 import Camera from 'react-native-camera';

 export default class BarcodeScan extends Component {

  constructor(props) {
    super(props);
    this.state = {
        qrcode: ''
    }
}

 onBarCodeRead = (e) => this.setState({qrcode: e.data});

 render () {
    return (
        <View  style={styles.container}>
            <Camera
                style={styles.preview}
                onBarCodeRead={this.onBarCodeRead}
                ref={cam => this.camera = cam}
                aspect={Camera.constants.Aspect.fill}
                >
                    <Text style={{
                        backgroundColor: 'white'
                    }}>{this.state.qrcode}</Text>
                </Camera>
          </View>
        )
    }

}

  const styles = StyleSheet.create({
  container: {
   flex: 1,
   flexDirection: 'row',
  },
   preview: {
   flex: 1,
   justifyContent: 'flex-end',
   alignItems: 'center'
  }
  });

多亏了这个人,https://github.com/dwicao/react-native-panel/issues/4
我能够通过替换包 'react-native-camera'.

的 index.js 中的以下内容来解决此问题

替换

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

 import React, { Component } from 'react';
 import PropTypes from 'prop-types';

如果有人通过搜索标题(我这样做)找到了这个线程,我会添加我的经验。有时使用 TSX,导入会变得有点奇怪。对我有用的是使用这个导入:

import * as PropTypes from 'prop-types'

我也需要对 React 本身做同样的事情,否则它也不起作用:

import * as React from 'react'

到目前为止,这是我需要为此执行此操作的仅有的两个导入。