解决ReactNavigation中Navigator嵌套问题
来源:互联网 发布:根据端口号查找进程 编辑:程序博客网 时间:2024/05/21 21:46
需求:由主页MainScreen
跳转到站内信页面MessageScreen
,在MessageScreen
存在自定义的TitleBar
和3个Tab布局。
采用如下方式无法自定义Title
import { TabNavigator } from "react-navigation";class RecentChatsScreen extends React.Component { render() { return <Text>List of recent chats</Text> }}class AllContactsScreen extends React.Component { render() { return <Text>List of all contacts</Text> }}const MessageNavigator = TabNavigator({ Recent: { screen: RecentChatsScreen }, All: { screen: AllContactsScreen },});
const SimpleApp = StackNavigator({ Main: { screen: MainScreen }, Message: { screen: MessageNavigator },});
**解决方案:在组件中嵌套Navigator
并且需要将router进行传递,方便子页面获取navigation**
class MessageWrappingScreen extends React.Component { render() { return ( <View> <TitleBar/> <MessageNavigator navigation={this.props.navigation}/> </View> ); }}MessageWrappingScreen.router = MainScreen.router;
const SimpleApp = StackNavigator({ Main: { screen: MainScreen }, Message: { screen: MessageWrappingScreen },});
文档链接:https://reactnavigation.org/docs/intro/nesting
阅读全文
0 0
- 解决ReactNavigation中Navigator嵌套问题
- 解决VerticalViewPager中嵌套ScrollView滑动问题
- 解决ScrollView中ListView嵌套问题
- 解决Anaconda navigator闪退问题
- 完美解决window.navigator.geolocation.getCurrentPosition,在IOS10系统中无法定位问题
- 完美解决window.navigator.geolocation.getCurrentPosition,在IOS10系统中无法定位问题
- 解决嵌套游标问题
- 解决窗口嵌套问题
- 解决窗口嵌套问题
- 解决Fragment嵌套问题
- 解决!Gallery中嵌套ListView,Gallery不能滑动的问题
- 解决ScrollView中嵌套ListView滚动效果冲突问题
- 解决ListView中嵌套的GridView显示不正常的问题
- android 中ListView嵌套CheckBox解决复用相关问题
- 解决ScrollView中嵌套ListView滚动效果冲突问题
- Android开发--解决ScrollView中嵌套ListView问题
- 解决ScrollView中listview、gridview的嵌套问题
- listview中嵌套子listview,解决子listview点击问题
- dedecms中的sql操作方法
- C语言输入成绩等级输出对应分数段
- 中二病
- 实习记录1 堡垒机相关
- java激光推送
- 解决ReactNavigation中Navigator嵌套问题
- Matlab2017a:mex问题解决
- springboot整合redis进行数据操作
- 源码解析-unregister
- 深度学习方法(十):卷积神经网络结构变化——Maxout Networks,Network In Network,Global Average Pooling
- Python--lnheritance,Priavte and class-local
- xampp在linux下无法使用mysql命令
- Linux下修改/设置环境变量JAVA_HOME
- verilog里同一个寄存器问什么不能在不同的always里分别操作?