0

テキストを押したときに変更がナビゲートされる単純なAndroidアプリケーションを作成しました。アプリは正常に動作しますが、テキストに触れると内容は変わらず、ナビゲーションも見られません。エラーhereを見ることができます。私はまた、コードを提供しています画面をナビゲートする - ネイティブに反応する

import React, { Component, PropTypes } from 'react'; 
import { Navigator, Text, TouchableHighlight, View, AppRegistry} from 
'react-native'; 

export default class SimpleNavigationApp extends Component { 
constructor(props){ 
    super(props); 
    this.state={ 
    title: 'My Initial Scene', 
    } 
} 

    render() { 
    return (
     <Navigator 
     initialRoute={{ title: 'My Initial Scene', index: 0 }} 
     renderScene={(route, navigator) => 
      <MyScene 
      title={route.title} 

      // Function to call when a new scene should be displayed 
      onForward={() => { 
       const nextIndex = route.index + 1; 
       navigator.push({ 
       title: 'Scene ' + nextIndex, 
       index: nextIndex, 
       }); 
      }} 

      // Function to call to go back to the previous scene 
      onBack={() => { 
       if (route.index > 0) { 
       navigator.pop(); 
       } 
      }} 
      /> 
     } 
     /> 
    ) 
    } 
} 

class dhrumil extends Component { 
    static propTypes = { 
    title: PropTypes.string.isRequired, 
    onForward: PropTypes.func.isRequired, 
    onBack: PropTypes.func.isRequired, 
    } 
    render() { 
    return (
     <View> 
     <Text>Current Scene: { this.props.title }</Text> 
     <TouchableHighlight onPress={this.props.onForward}> 
      <Text>Tap me to load the next scene</Text> 
     </TouchableHighlight> 
     <TouchableHighlight onPress={this.props.onBack}> 
      <Text>Tap me to go back</Text> 
     </TouchableHighlight> 
     </View> 
    ) 
    } 
} 

AppRegistry.registerComponent("dhrumil",()=>dhrumil); 

あなたがエラーで見ることができるように、タイトルは、テキストの後に表示されていない「私の現在のシーン:」。これをどうすれば解決できますか?

答えて

0

最初のは、エクスポートのデフォルトクラスSimpleNavigationAppが呼び出されることはありません。

あなたは別のjsファイルに入れて、クラス

をdhrumilするためにそれをインポートする必要があります。

, 'react-native'のimport {navigator}はサポートされなくなりました。

詳細なナビゲーションドキュメントについてはhttps://facebook.github.io/react-native/docs/navigation.htmlをお読みください。

関連する問題