未显示React-native Tab-navigator

时间:2017-08-28 09:43:33

标签: reactjs react-native react-navigation

我想在我的应用程序中显示一个TabNavigator。因为我正在使用this但现在我不得不重构我的代码,它不再工作了。 这是我的代码:

主要班级:

import React, {Component} from 'react';
import {View,Text, WebView,StyleSheet} from 'react-native';
import { TabNavigator } from "react-navigation";
const Navigation = TabNavigator({
  Prod: { screen: Prod },
  ContinuousDeployment: { screen: ContinuousDeployment },
});
export default class Mattermost extends Component{
    constructor(props){
        super(props);

        this.state = ({
            MMAUTHTOKEN : null,
            BASICAUTH : null,
        });
    }
    render(){
        if(this.state.MMAUTHTOKEN === undefined || this.state.MMAUTHTOKEN === null){
            return(
                /*Another page , not the tab*/
            );
        }
        else if(this.state.BASICAUTH === undefined || this.state.BASICAUTH === null){
                return(
                    /*Another page , not the tab*/
                );
        }
        else{
            return <View>{Navigation}</View>;
        }
    }

这是我的一个页面的类:

import React,{Component} from 'react';
import {View,Text,StyleSheet} from 'react-native';


export default class Prod extends Component{
    constructor(props){
        super(props);
    }

    static navigationOptions = {
        tabBarLabel: 'Prod',
        tabBarIcon: ({ tintColor }) => (
            <Image source={require('../Images/Icones/jenkins.png')} style={[styles.icon, {tintColor: tintColor}]}/>
        ),
    };

    put(){
    }
    render(){
        return (
            <View>
                <Text>Prod</Text>
            </View>
        );
    }
}
const styles = StyleSheet.create({
  icon: {
    width: 26,
    height: 26,
  },
});

以前工作得很好,但现在它显示白屏,没有标签,没有任何警告或错误。如果有人可以帮助我,那将非常酷!在此先感谢,Alex

1 个答案:

答案 0 :(得分:2)

更改此

return <View>{Navigation}</View>;

return <View><Navigation /></View>;

return <Navigation />;

应该解决这个问题。