简体   繁体   English

React-Native-未定义不是对象(“评估_react3.default.PropTypes.shape”)

[英]React-Native – undefined is not an object (“evaluating _react3.default.PropTypes.shape”)

I am going through a tutorial on React Native that uses the 'Navigator' object, which apparently has been deprecated since the tutorial was posted. 我正在阅读关于React Native的使用'Navigator'对象的教程,自发布教程以来,该对象显然已被弃用。 There is some errata included that supposedly has a fix to the code, but that still doesn't prevent the above error. 其中包含一些勘误表,据说可以修复该代码,但仍不能防止上述错误。 I've searched other questions on this topic, but the solutions don't work for me. 我已经搜索了有关此主题的其他问题,但是解决方案对我不起作用。

I've installed 'react-native-deprecated-custom-components' and 'prop-types' and included them in the code below. 我已经安装了'react-native-deprecated-custom-components''prop-types' ,并将它们包含在下面的代码中。

Here is the code: 这是代码:

import React, { Component } from 'react';
import {
  Platform,
  StyleSheet,
  Text,
  View,
  Image,
  TouchableOpacity
} from 'react-native';
import { Navigator } from 'react-native-deprecated-custom-components';
import PropTypes from 'prop-types';
import Quote from './quote';

const zenImage = require ('./assets/zen_circle.png');

const navScene = {
  sceneContainer: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'stretch'
  }
}

export default class App extends Component<{}> {
  // Following two lines of code were included in the errata, but cause
  // an unexpected token error right on the first period below.
  // Navigator.sceneStyle = {navScene.sceneContainer};
  // sceneStyle={styles.sceneContainer};
  render() {
    return (
      <Navigator
        initialRoute={{ name: 'StartScreen' }}
        renderScene={(route, navigator) => {
          return (
            <View style={styles.container}>
              {/*<TouchableOpacity style={styles.button} onPress={() => {alert('I was pressed!')}}>
                <Image source={zenImage} style={styles.buttonImage} />
              </TouchableOpacity>
              <Text style={styles.readyText}>I'm ready to relax...</Text>*/}
              <Quote quoteText="Amazing quote!" quoteSource="- Great source!"/>
            </View>
          );
        }}
      />

    );
  }
}

Thanks for any help you can provide! 感谢您的任何帮助,您可以提供!

Uninstall the already installed react-native-deprecated-custom-components like below. 卸载已安装的react-native-deprecated-custom-components,如下所示。

npm uninstall --save react-native-deprecated-custom-components

After that install it as follows. 之后安装它如下。

npm install --save https://github.com/facebookarchive/react-native-custom-components.git

Now run your application and you issue will be fixed. 现在运行您的应用程序,您的问题将得到解决。

most of the times these errors happen because of the cached stuff.. 大多数情况下,这些错误是由于缓存的内容而发生的。

try this command and check: 尝试以下命令并检查:

cd android & gradlew clean & cd .. & rm -rf node_modules/ & npm cache clean --force & yarn install & react-native run-android

遇到同样的问题,似乎他们还没有更新npm软件包,但是github分支的proptypes更改了,将其放入package.json中:

"react-native-deprecated-custom-components": "github:facebookarchive/react-native-custom-components",

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 React-Native - undefined 不是一个对象(“评估 _react3.default.PropTypes.shape”) - React-Native - undefined is not an object (“evaluating _react3.default.PropTypes.shape”) 错误 PropTypes React Native undefined is not an object(评估'_propTypes.default.nymber.isRequired') - Error PropTypes React Native undefined is not an object (evaluating '_propTypes.default.nymber.isRequired') React native Undefined不是对象(评估&#39;_react3.default.PropType.shape&#39;)吗? - React native Undefined is not an object(evaluating'_react3.default.PropType.shape')? React native Undefined不是对象(评估&#39;_react3.default.PropType.shape&#39;) - React native Undefined is not an object(evaluating'_react3.default.PropType.shape') React Native,未定义不是 object(评估 '_reactNative.Image.propTypes.resizeMode') - React Native, undefined is not an object (evaluating ‘_reactNative.Image.propTypes.resizeMode’) 未定义不是对象(评估&#39;_react.PropTypes.object&#39;) - undefined is not an object (evaluating '_react.PropTypes.object') React-Native Undefined不是对象(评估&#39;this.refs。[&#39;DRAWER&#39;]) - React-Native Undefined is not an object (evaluating 'this.refs.['DRAWER']) react-native:TypeError:undefined 不是 object(正在评估“this.state”) - react-native : TypeError:undefined is not an object (evaluating 'this.state') 【React-native】undefined不是对象(评估&#39;_this.props.navigation.navigate&#39;) - 【React-native】undefined is not an object (evaluating '_this.props.navigation.navigate') React-native - Dropdownpicker - undefined 不是对象(评估“choice.label”) - React-native - Dropdownpicker - undefined is not an object(evaluating 'choice.label')
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM