react-native - 如何在本机反应中导航到 BottomTabNavigator 内的另一个导航?
问题描述
我想从 BottomTabNavigator 导航到堆栈导航器。但是,当我在 BottomTabNavigator 中分配堆栈导航器时,会The component for route 'route_name' must be a React component
显示错误。
这是我的代码:
const BottomTabNavigator = createAppContainer(createBottomTabNavigator(
{
Home: {
screen: HomeScreen,
navigationOptions:{
tabBarLabel: 'Home',
tabBarIcon: ({ tintColor }) => (
<View>
<Icon style={[{color: tintColor}]} size={25} name={'ios-home'}/>
</View>)
}
},
Profile: {
screen: ProfileStackNavigator,
navigationOptions:({ navigation }) => ({
tabBarLabel: 'Profile',
tabBarIcon: ({ tintColor }) => (
<View>
<Icon style={[{color: tintColor}]} size={25} name={'ios-contact'}/>
</View>),
}),
},
},
{
tabBarOptions: {
activeTintColor: '#2383F7',
// inactiveTintColor: 'gray',
},
}
));
const ProfileStackNavigator = createAppContainer(createStackNavigator({
ProfileHome:
{
screen: ProfileScreen,
// headerMode: 'none',
navigationOptions:
{
header: null,
}
},
ChangePasswordFromProfile:
{
screen: ChangePasswordScreen,
// navigationOptions:
// {
// header: null,
// }
}
}))
这是导航的所有版本:
“反应导航”:“^4.0.10”,“反应导航抽屉”:“^2.3.3”,“反应导航堆栈”:“^1.10.3”,“反应导航标签” : "^2.6.2"
提前致谢
解决方案
在您创建 BottomTabNavigator 时,尚未创建 ProfileStackNavigator 变量。所以,把你的const ProfileStackNavigator = ...
代码移到上面const BottomTabNavigator = ...
推荐阅读
- python - 当我尝试提取文本并将其填充到文本文件中时,我的代码给了我错误“'JpegImageFile' object is not subscriptable”
- google-sheets - 将所有行设为相同的格式标准
- nginx - 如何使 Nginx 代理传递与外部请求一起工作到节点
- python - 检查字典列表中是否存在重复值并更新所述重复值
- maven - 黄瓜选项未从 mvn cli 命令运行标记场景
- r - R,错误:$ 运算符对 fastai 中的原子向量无效
- postgresql - 为什么一段时间后运行查询时,seq/index 扫描需要这么长时间?如何让它快速?
- c# - 各种bool的机器码区别是什么?查询?
- client-server - 标准代理注册协议
- php - 警告:mysqli_connect(): (HY000/2002): No such file or directory in