Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.4k views
in Technique[技术] by (71.8m points)

javascript - This navigator has both navigation and container props in React Native

I'm trying to make a bottom Navbar in React Native and I came up with this error : "This navigator has both navigation and container props, so it is unclear if it should own its own state. Remove props: "route" if the navigator should get its state from the navigation prop. If the navigator should maintain its own state, do not pass a navigation prop."

I try to change the line at bottom : export default createAppContainer(TabNavigator); to export default (TabNavigator);

But when I do that I have another error saying "Cannot read property 'routes' of undefined. Did someone came across this error and can help?

import React, {Component} from 'react'
import {Text, View, StyleSheet } from 'react-native';
import {createBottomTabNavigator, createAppContainer } from 'react-navigation';
import {createMaterialBottomTabNavigator} from 'react-navigation-material-bottom-tabs';
import {Icon} from 'react-native-elements';

import Profile from "./Profile";
import Appointment from "./Appointment";



const styles = StyleSheet.create({

   homeText: {
      fontSize: 40,
      
   },

   homeCont: {
      flex: 1,
      justifyContent: "center",
      alignItems: "center"
   }

})

class Home extends Component {

   render() {

      return(

         <View style={styles.homeCont}>
            <Text style={styles.homeText}>HOME SCREEN</Text>
            
         </View>
    
     
      )

   }

   

}

const TabNavigator= createMaterialBottomTabNavigator({

   Home: {screen:Home,
          navigationOptions: {
             tabBarLabel: 'Home',
             activeColor: '#ff0000',
             inactiveColor: '#000000',
             barStyle: {backgroundColor: '#67baf6'},
             tabBarIcon:() => (
                <View>
                   <Icon name={'home'} size={25} style={{color:'#ff000'}} />
                </View>
             )
          }
   },
   Appointment: {screen:Appointment,
      navigationOptions: {
         tabBarLabel: 'Appointment',
         activeColor: '#ff0000',
         inactiveColor: '#000000',
         barStyle: {backgroundColor: '#67baf6'},
         tabBarIcon:() => (
            <View>
               <Icon name={'calendar'} size={25} style={{color:'#ff000'}} />
            </View>
         )
      }
},

Profile: {screen:Profile,
   navigationOptions: {
      tabBarLabel: 'Profile',
      activeColor: '#ff0000',
      inactiveColor: '#000000',
      barStyle: {backgroundColor: '#67baf6'},
      tabBarIcon:() => (
         <View>
            <Icon name={'person'} size={25} style={{color:'#ff000'}} />
         </View>
      )
   }
}


});

export default (TabNavigator);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...