react-navigation / react-navigation/react-navigation.github.io
createDrawerNavigator and createStackNavigator not working fine with each other.
还没有人认领这个 Issue。
- 主要语言
- JavaScript
- 星标
- 324
- 派生
- 2k
- PR 合并指标
- 30 天内没有已合并 PR
描述
I'm using createDrawerNavigator and createStackNavigator. But when I implemented Drawer Navigator in my app its disabling my navigationOption and defaultNavigationOption. I want different header title for each screen by navigationOptions and also I want to set same header background color for all over the app by defaultNavigationOptions. I also tried to set navigationOption in the class component but not working there also. I have tried several ways but not working good for me.
I'm using expo. react-navigation version is 3.11.1
----------Route.js-----------
import { createStackNavigator,
createAppContainer,
createSwitchNavigator,
createDrawerNavigator}
from 'react-navigation';
import Splash from '../app/component/Splash';
import Login from '../app/component/Login';
import SignUp from './component/signup';
import InitialScreen from './component/InitialScreen';
import CreateCircle from './component/CreateCircle';
export const AppDrawerNavigator = createDrawerNavigator(
{
initialScreen:{
screen: InitialScreen,
drawerLabel: "Initial Screen",
},
createCircle:{
screen: CreateCircle,
drawerLabel: "Create Circle",
}
},
{
drawerPosition: "left",
drawerWidth: 300,
},
)
// AppDrawerNavigator.navigationOptions = {
// title: 'My Chats',
// headerBackTitleVisible: false,
// headerStyle: {
// backgroundColor: '#87dfff',
// },
// headerTitleStyle: {
// textAlign:"center",
// flex:1
// },
// };
// THIS ABOVE COMMENTED THING WORKS BUT I WANT DIFFERENT HEADER NAME FOR ALL THE PAGES
const AppStack = createStackNavigator({
initialScreen:{
screen: InitialScreen,
navigationOptions: {
headerTitle: "Initial Screen" // Not showing me this title when I use createDrawerNavigator
}
},
createCircle:{
screen: CreateCircle,
navigationOptions: {
headerTitle: "Second Screen" // Not showing me this title when I use createDrawerNavigator
}
},
},
{
defaultNavigationOptions: {
headerBackTitleVisible: false,
headerStyle: {
backgroundColor: '#87dfff',
},
headerTitleStyle: {
textAlign:"center",
flex:1
},
}
// defaultNavigationOptions also does not working after using createDrawerNavigator
}
)
const AuthStack = createStackNavigator({
login: {
screen: Login,
navigationOptions: {
header: null
}
},
signup:{
screen: SignUp,
navigationOptions: {
header: null
}
},
Drawer:{screen: AppDrawerNavigator } // if I Comment out this line, all navigationOptions working fine.
// but I want Drawer in my app
},
)
const SwitchNavigator = createSwitchNavigator(
{ Splash: Splash,
Auth: AuthStack,
App: AppStack
},
{initialRouteName : 'Splash'}
)
export default createAppContainer(SwitchNavigator)
--------App.js------------
import React from 'react'
import {View} from 'react-native'
import NavRoutes from './app/Routes'
export default class App extends React.Component{
render(){
return(
)
}
}
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 Route.js 开始,然后将 createDrawerNavigator 和 createStackNavigator 的嵌套配置与 React Navigation 3.x 的 navigation-options 文档进行比较。通过 App.js 运行 Expo 应用,并验证每个 drawer 屏幕都显示其配置的标题,同时共享的 header 样式仍会应用;记录受支持的嵌套配置和任何必要的更改。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, react-native
- 领域
- mobile
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100