2017-11-21 11 views
0

「Navigator」オブジェクトを使用するReact Nativeのチュートリアルを行っていますが、このチュートリアルは、投稿されました。コードに修正が加えられているエラッタがいくつか含まれていますが、それでも上記のエラーは防げません。このトピックに関する他の質問を検索しましたが、解決策は私のためには機能しません。React-Native - 未定義はオブジェクトではありません( "evaluation_react3.default.PropTypes.shape")

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

    ); 
    } 
} 

ありがとう!既にインストールされているが

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

あなたはRM -rf node_modules && NPM私を試してみたのですか? – challenger

答えて

1

アンインストール反応する:

+0

はい、それはやりました。ありがとうございました! –

0

が同じ問題に遭遇し、彼らは彼らのNPMパッケージを更新していないようにそれがようだが、彼らのgithubの分岐はproptypesの変更を持っている、あなたのpackage.jsonにこれを投げます次のような非推奨のカスタムコンポーネント。

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

その後、次のようにインストールします。

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

ここでアプリケーションを実行すると、問題は修正されます。

+0

それを試しても、私には同じエラーが表示されます。 –

+0

再インストールしましたか? 'rm -rf node_modules/&& npm install' –

1

これらのエラーが原因で、キャッシュされたものの起こる回数の最も..

は、このコマンドを試してみて確認してください。

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

関連する問題