反应生态导航器问题



对不起,我得到此错误元素类型是无效的:预期字符串(用于内置组件)或类/函数(对于复合组件),但got:undfened.check.check the the the the the the"导航器"的渲染方法。

here's the code;

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  Navigator,
  TouchableHighlight
} from 'react-native';
import ButtonPage from './jara/initialpage';
import  NotePage from'./jara/Notescreen';
import HomeScreen from './jara/HomePage';
 var NavigationBarRouteMapper = {
  LeftButton(route, navigator, index, navState) {
    if(index > 0) {
      return (
        <TouchableHighlight
          underlayColor="transparent"
          onPress={() => { if (index > 0) { navigator.pop() } }}>
          <Text style={ styles.leftNavButtonText }>Back</Text>
        </TouchableHighlight>        
          );
    } 
    else { return null }
  },
  RightButton(route, navigator, index, navState) {
    if (index <= 0) return (
        <ButtonPage
        onPress ={() => {
        navigator.push({
        });
      }}
       customText = 'create Note'
       />  
         );
  },
  Title(route, navigator, index, navState) {
    return (
        <Text style={ styles.title }>Home Page</Text>
        );
  }
};

class NavProject extends Component{
    renderScene(route,navigator){
       return(
           <route.component navigator = {navigator}/>
             );
           }
 render(){
     return(
         <View style = {styles.MainContainer}>
           <View style = {styles.container}>
              <ButtonPage/>
           </View>
         <Navigator
             initialRoute ={{page: 'Home'}}
             renderScene ={this.renderScene.bind(this)}
             navigationBar ={
              <Navigator.NavigationBar
                routeMapper = {NavigationBarRouteMapper}
            />
            }
            configScene ={(route,navigator) =>
            Navigator.sceneConfigs.floatFromRight}
         />
         </View>     
     );
  }
 }
 class ReactNote extends Component{
   renderScene(route,navigator){
               if(index <= 0){
                return(
                    <View style = {styles.container}>
                      <HomeScreen
                      onPress={() =>{
                      navigator.push({});
                }}
            />
                    </View>                       
                      );
                 }
       else if(index > 0){
            return(
            <View styles ={styles.scontainer}>
                <NotePage
                onPress={() =>{
                navigator.pop();
                }}
            />
                  />
            </View>    
            );
       }
   }
}

const styles =  StyleSheet.create({
   container:{
                flex:1,
                justifyContent:'center',
                alignItems:'center',
   },
      container:{
         backgroundColor:'blue',
         flex:1,
    },
  scontainer:{
      backgroundColor:'lightblue',
      flex:1,
  }
});

AppRegistry.registerComponent('NavProject', ()=> NavProject);

i后来发现,RenderScene的工作原理与NavigationRoutemapper相似,在该范围内,对于所引用的单个组件页面,如上所述。'navigator.push({});'和'navigator.pop();'在他们各自的页面中。为我工作。此外,我摆脱了renderscene.bind(this),并直接在Renderscene Props下写了代码,我认为它有效。

相关内容

  • 没有找到相关文章

最新更新