我正在使用React-Navigation
在React-Native上构建一个应用程序现在,在我内部使用的是Stack-Navigation
和TabNavigator
(已更新DrawerNavigator
)
import {
createStackNavigator,
TabNavigator,
DrawerNavigator
} from 'react-navigation';
import CoinCapCharts from "./src/container/CoinCapCharts.js"
import CoinCap from './src/container/CoinCap.js';
//THis is being Exported to App.js
export const Tab = TabNavigator({
TabA: {
screen: CoinCap
},
TabB: {
screen: CoinCap
}
}, {
order: ['TabA', 'TabB'],
animationEnabled: true,
})
export const MyScreen = createStackNavigator({
Home: {
screen: CoinCap
},
CoinCapCharts: {
screen: CoinCapCharts
}
},{
initialRouteName: 'Home',
headerMode: 'none'
});
export const Drawer = DrawerNavigator({
Tabs: { screen: Tab },
Stack: { screen: MyScreen },
})
我将其导入App.js中,我正在做类似的事情
import React from 'react';
import {
Drawer
}from './Screen.js';
import {
View
} from 'react-native';
export default class App extends React.Component {
render() {
return (
<View>
<Drawer/>
<Tab/>
</View>
);
}
}
现在,这确实是我第一次运行应用程序时显示的Tab,但是导航到其他屏幕并返回后,它似乎不再显示该Tab
[问题:] ,我可能做错了什么以及如何解决?
答案 0 :(得分:1)
尝试在另一个中定义一个。 像这样:
const Tab = TabNavigator({
TabA: {
screen: Home
},
TabB: {
screen: Home
}
}, {
order: ['TabA', 'TabB'],
animationEnabled: true,
})
export const MyStack = createStackNavigator({
Home: {
screen: Home
},
CoinCapCharts: {
screen: CoinCapCharts
},
Tab: {
screen: Tab
},
},{
initialRouteName: 'Home',
headerMode: 'none'
});
现在,渲染MyStack(不确定Screen
是最好的名字:)
export default class App extends React.Component {
render() {
return (
<View>
<MyStack />
</View>
);
}
}