gpt4 book ai didi

react-native - react-navigation tab navigator 屏幕内容未显示/屏幕为空白问题

转载 作者:行者123 更新时间:2023-12-04 03:05:03 24 4
gpt4 key购买 nike

我对 react-navigation 选项卡导航器有疑问。屏幕内容未显示/屏幕为空白。有任何想法吗 ?这是我的导航器结构:

import { StackNavigator, TabNavigator } from 'react-navigation';
import PeopleList from './PeopleList';
import CompanyList from './CompanyList';
import AddPerson from './AddPerson';
const Navigation = TabNavigator({
People: { screen: PeopleList },
Person: { screen: AddPerson },
Company: { screen: CompanyList },
}, {
tabBarOptions: {
activeTintColor: 'white',
inactiveTintColor: '#80cbc4',
swipeEnabled: true,
showLabel: false,
style: {
backgroundColor: '#26a69a',
},
},
});
export default Navigation;

更新:

这是包含渲染方法的 App.js 文件:

    import React, {Component} from 'react';
import {StyleSheet, Text, View} from 'react-native';
import firebase from 'firebase';
import {Provider} from 'react-redux';
import {createStore} from 'redux'
import Login from './Login';
import Loader from './Loader';
import Navigation from './Navigation';
import reducers from '../reducers/PeopleReducer';

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

const store = createStore(reducers);

export default class App extends Component {
state = {
loggedIn: null
};

componentWillMount() {
firebase.initializeApp({
apiKey: "xxxxxxxxxxxxxxxxxxx",
authDomain: "xxxxxxxxxxxxxxxxxxx",
databaseURL: "xxxxxxxxxxxxxxxxxxx",
projectId: "xxxxxxxxxxxxxxxxxxx",
storageBucket: "xxxxxxxxxxxxxxxxxxx",
messagingSenderId: "xxxxxxxxxxxxxxxxxxx"
});

firebase
.auth()
.onAuthStateChanged((user) => {
if (user) {
this.setState({loggedIn: true});
} else {
this.setState({loggedIn: false});
}
});
}

renderInitialView() {
switch (this.state.loggedIn) {
case true:
return <Navigation/> /*exists above*/
case false:
return <Login/>;
default:
return <Loader size="large"/>;
}
}
render() {
return (
<Provider store={store}>
<View style={styles.container}>
{this.renderInitialView()}
</View>
</Provider>
);
}
}

我确定它适用于第一个 switch 情况,但出现黑屏,我不知道原因。

最佳答案

render() {
return (
<Provider store={store}>
<View style={styles.container}>
{this.renderInitialView()}
</View>
</Provider>
);
}
}

移除标签导航不能包裹在标签中,像这样。

render() {
return (
<Provider store={store}>

{this.renderInitialView()}

</Provider>
);
}
}

这样就可以了。

关于react-native - react-navigation tab navigator 屏幕内容未显示/屏幕为空白问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45361851/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com