Javascript 反应本机–;undefined不是对象(“;evaluation"react3.default.PropTypes.shape”;)

Javascript 反应本机–;undefined不是对象(“;evaluation"react3.default.PropTypes.shape”;),javascript,react-native,Javascript,React Native,我正在阅读一篇关于React Native的教程,该教程使用了“Navigator”对象,自教程发布以来,该对象显然已被弃用。其中包含一些勘误表,可能对代码进行了修复,但这仍然不能防止上述错误。我已经搜索了关于这个主题的其他问题,但这些解决方案对我来说并不适用 我已经安装了'react-native-deprecated-custom-components'和'prop-types',并将它们包含在下面的代码中 代码如下: import React, { Component } from 're

我正在阅读一篇关于React Native的教程,该教程使用了“Navigator”对象,自教程发布以来,该对象显然已被弃用。其中包含一些勘误表,可能对代码进行了修复,但这仍然不能防止上述错误。我已经搜索了关于这个主题的其他问题,但这些解决方案对我来说并不适用

我已经安装了
'react-native-deprecated-custom-components'
'prop-types'
,并将它们包含在下面的代码中

代码如下:

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>
          );
        }}
      />

    );
  }
}
import React,{Component}来自'React';
进口{
平台,
样式表,
文本,
看法
形象,,
可触摸不透明度
}从“反应本机”;
从“react native Disprecated custom components”导入{Navigator};
从“道具类型”导入道具类型;
从“./Quote”导入报价;
const zenImage=require('./assets/zen_circle.png');
常量导航场景={
场景容器:{
弹性:1,
为内容辩护:“中心”,
对齐项目:“拉伸”
}
}
导出默认类应用程序扩展组件{
//勘误表中包括以下两行代码,但原因是
//就在下面的第一个期间发生意外的令牌错误。
//Navigator.sceneStyle={navScene.sceneContainer};
//sceneStyle={style.sceneContainer};
render(){
返回(
{
返回(
{/*{alert('我被按了!')}>
我准备好放松了…*/}
);
}}
/>
);
}
}

谢谢你能提供的任何帮助

遇到了同样的问题,他们似乎没有更新他们的npm包,但他们的github分支有proptypes更改,请将此添加到您的包中。json:

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

遇到同样的问题,他们似乎没有更新他们的npm包,但是他们的github分支有proptypes更改,请将此添加到您的包中。json:

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

卸载已安装的react native不推荐使用的自定义组件,如下所示

npm uninstall --save react-native-deprecated-custom-components
之后,按如下方式安装它

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

现在运行应用程序,问题将得到解决。

卸载已安装的react native不推荐的自定义组件,如下所示

npm uninstall --save react-native-deprecated-custom-components
之后,按如下方式安装它

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

现在运行应用程序,问题就会得到解决。

大多数情况下,这些错误都是由于缓存的内容而发生的

尝试此命令并检查:

cd安卓&gradlew清洁&cd..&rm-rf节点\ U模块/&npm缓存清理--强制和纱线安装&反应本机运行android

大多数情况下,这些错误都是由于缓存的内容而发生的

尝试此命令并检查:

cd安卓&gradlew清洁&cd..&rm-rf节点\ U模块/&npm缓存清理--强制和纱线安装&反应本机运行android

您重新安装了吗<代码>rm-rf节点\ U模块/&&npm安装您重新安装了吗
rm-rf node_模块/&&npm安装
您尝试过rm-rf node_模块和&npm i吗?您尝试过rm-rf node_模块和&npm i吗?