Switch Navigator Two headers
I've build an app with a BottomTabNavigator
and createSwitchNavigator
.
If I declare my screen inside the MainTabNavigator
, the top header of my screens work as intended, but as soon as I import my screens (for example my HomeScreen
) I get a double header.
I've tried adding:
headerMode: 'none',
navigationOptions:
headerVisible: false,
To my StackNavigator
, but doesn't seem to have an effect.
I've tried looking at similar posted questions, but have not been set off into the right direction.
Is anyone else familiar with this problem and how to solve it?
App JS
import React from 'react';
import View, Text from 'react-native';
import createStackNavigator,createBottomTabNavigator from 'react-navigation';
import AppNavigator from './navigation/AppNavigator';
export default class App extends React.Component
render()
return <AppNavigator />;
App Navigator
import React from 'react';
import createSwitchNavigator from 'react-navigation';
import MainTabNavigator from './MainTabNavigator';
export default createSwitchNavigator(
Main: MainTabNavigator,
,
);
MainTabNavigator
import React from 'react';
import Button, Text, View from 'react-native';
import Ionicons from '@expo/vector-icons';
import createStackNavigator, createBottomTabNavigator from 'react-navigation';
import HomeScreen from '../screens/clubs/Home';
import DetailsScreen from '../screens/clubs/Details';
class SettingsScreen extends React.Component
static navigationOptions =
// title: ' Alpha',
header: null,
;
render()
return (
<View style= flex: 1, justifyContent: 'center', alignItems: 'center' >
<Text>Settings!</Text>
<Button
title="Go to Home"
onPress=() => this.props.navigation.navigate('Home')
/>
<Button
title="Go to Details"
onPress=() => this.props.navigation.navigate('Details')
/>
</View>
);
const HomeStack = createStackNavigator(
Home: screen: HomeScreen ,
Details: screen: DetailsScreen ,
);
const SettingsStack = createStackNavigator(
Settings: screen: SettingsScreen ,
Details: screen: DetailsScreen ,
);
export default createBottomTabNavigator(
Home: screen: HomeStack ,
Settings: screen: SettingsStack ,
,
navigationOptions: ( navigation ) => (
tabBarIcon: ( focused, tintColor ) =>
const routeName = navigation.state;
let iconName;
if (routeName === 'Home')
iconName = `ios-information-circle$focused ? '' : '-outline'`;
else if (routeName === 'Settings')
iconName = `ios-information-circle$focused ? '' : '-outline'`;
return <Ionicons name=iconName size=25 color=tintColor />;
,
),
tabBarOptions:
activeTintColor: '#DD016B',
inactiveTintColor: 'white',
tabStyle:
width: 100,
backgroundColor: 'black',
,
labelStyle:
color: 'white',
,
,
);
Home JS
import React, Component from 'react';
import
AppRegistry,
ListView,
View,
Text,
StyleSheet,
Image,
Button,
TouchableOpacity,
TextInput,
ScrollView,
Icon,
FlatList,
from 'react-native';
import createStackNavigator, from 'react-navigation';
export class HomeScreen extends Component
static navigationOptions =
// title: ' Alpha',
header: null,
;
....... App content
AppRegistry.registerComponent('App', () => App)
export default createStackNavigator(
Home:
screen: HomeScreen,
,
,
initialRouteName: 'Home',
);
react-native react-navigation
add a comment |
I've build an app with a BottomTabNavigator
and createSwitchNavigator
.
If I declare my screen inside the MainTabNavigator
, the top header of my screens work as intended, but as soon as I import my screens (for example my HomeScreen
) I get a double header.
I've tried adding:
headerMode: 'none',
navigationOptions:
headerVisible: false,
To my StackNavigator
, but doesn't seem to have an effect.
I've tried looking at similar posted questions, but have not been set off into the right direction.
Is anyone else familiar with this problem and how to solve it?
App JS
import React from 'react';
import View, Text from 'react-native';
import createStackNavigator,createBottomTabNavigator from 'react-navigation';
import AppNavigator from './navigation/AppNavigator';
export default class App extends React.Component
render()
return <AppNavigator />;
App Navigator
import React from 'react';
import createSwitchNavigator from 'react-navigation';
import MainTabNavigator from './MainTabNavigator';
export default createSwitchNavigator(
Main: MainTabNavigator,
,
);
MainTabNavigator
import React from 'react';
import Button, Text, View from 'react-native';
import Ionicons from '@expo/vector-icons';
import createStackNavigator, createBottomTabNavigator from 'react-navigation';
import HomeScreen from '../screens/clubs/Home';
import DetailsScreen from '../screens/clubs/Details';
class SettingsScreen extends React.Component
static navigationOptions =
// title: ' Alpha',
header: null,
;
render()
return (
<View style= flex: 1, justifyContent: 'center', alignItems: 'center' >
<Text>Settings!</Text>
<Button
title="Go to Home"
onPress=() => this.props.navigation.navigate('Home')
/>
<Button
title="Go to Details"
onPress=() => this.props.navigation.navigate('Details')
/>
</View>
);
const HomeStack = createStackNavigator(
Home: screen: HomeScreen ,
Details: screen: DetailsScreen ,
);
const SettingsStack = createStackNavigator(
Settings: screen: SettingsScreen ,
Details: screen: DetailsScreen ,
);
export default createBottomTabNavigator(
Home: screen: HomeStack ,
Settings: screen: SettingsStack ,
,
navigationOptions: ( navigation ) => (
tabBarIcon: ( focused, tintColor ) =>
const routeName = navigation.state;
let iconName;
if (routeName === 'Home')
iconName = `ios-information-circle$focused ? '' : '-outline'`;
else if (routeName === 'Settings')
iconName = `ios-information-circle$focused ? '' : '-outline'`;
return <Ionicons name=iconName size=25 color=tintColor />;
,
),
tabBarOptions:
activeTintColor: '#DD016B',
inactiveTintColor: 'white',
tabStyle:
width: 100,
backgroundColor: 'black',
,
labelStyle:
color: 'white',
,
,
);
Home JS
import React, Component from 'react';
import
AppRegistry,
ListView,
View,
Text,
StyleSheet,
Image,
Button,
TouchableOpacity,
TextInput,
ScrollView,
Icon,
FlatList,
from 'react-native';
import createStackNavigator, from 'react-navigation';
export class HomeScreen extends Component
static navigationOptions =
// title: ' Alpha',
header: null,
;
....... App content
AppRegistry.registerComponent('App', () => App)
export default createStackNavigator(
Home:
screen: HomeScreen,
,
,
initialRouteName: 'Home',
);
react-native react-navigation
add a comment |
I've build an app with a BottomTabNavigator
and createSwitchNavigator
.
If I declare my screen inside the MainTabNavigator
, the top header of my screens work as intended, but as soon as I import my screens (for example my HomeScreen
) I get a double header.
I've tried adding:
headerMode: 'none',
navigationOptions:
headerVisible: false,
To my StackNavigator
, but doesn't seem to have an effect.
I've tried looking at similar posted questions, but have not been set off into the right direction.
Is anyone else familiar with this problem and how to solve it?
App JS
import React from 'react';
import View, Text from 'react-native';
import createStackNavigator,createBottomTabNavigator from 'react-navigation';
import AppNavigator from './navigation/AppNavigator';
export default class App extends React.Component
render()
return <AppNavigator />;
App Navigator
import React from 'react';
import createSwitchNavigator from 'react-navigation';
import MainTabNavigator from './MainTabNavigator';
export default createSwitchNavigator(
Main: MainTabNavigator,
,
);
MainTabNavigator
import React from 'react';
import Button, Text, View from 'react-native';
import Ionicons from '@expo/vector-icons';
import createStackNavigator, createBottomTabNavigator from 'react-navigation';
import HomeScreen from '../screens/clubs/Home';
import DetailsScreen from '../screens/clubs/Details';
class SettingsScreen extends React.Component
static navigationOptions =
// title: ' Alpha',
header: null,
;
render()
return (
<View style= flex: 1, justifyContent: 'center', alignItems: 'center' >
<Text>Settings!</Text>
<Button
title="Go to Home"
onPress=() => this.props.navigation.navigate('Home')
/>
<Button
title="Go to Details"
onPress=() => this.props.navigation.navigate('Details')
/>
</View>
);
const HomeStack = createStackNavigator(
Home: screen: HomeScreen ,
Details: screen: DetailsScreen ,
);
const SettingsStack = createStackNavigator(
Settings: screen: SettingsScreen ,
Details: screen: DetailsScreen ,
);
export default createBottomTabNavigator(
Home: screen: HomeStack ,
Settings: screen: SettingsStack ,
,
navigationOptions: ( navigation ) => (
tabBarIcon: ( focused, tintColor ) =>
const routeName = navigation.state;
let iconName;
if (routeName === 'Home')
iconName = `ios-information-circle$focused ? '' : '-outline'`;
else if (routeName === 'Settings')
iconName = `ios-information-circle$focused ? '' : '-outline'`;
return <Ionicons name=iconName size=25 color=tintColor />;
,
),
tabBarOptions:
activeTintColor: '#DD016B',
inactiveTintColor: 'white',
tabStyle:
width: 100,
backgroundColor: 'black',
,
labelStyle:
color: 'white',
,
,
);
Home JS
import React, Component from 'react';
import
AppRegistry,
ListView,
View,
Text,
StyleSheet,
Image,
Button,
TouchableOpacity,
TextInput,
ScrollView,
Icon,
FlatList,
from 'react-native';
import createStackNavigator, from 'react-navigation';
export class HomeScreen extends Component
static navigationOptions =
// title: ' Alpha',
header: null,
;
....... App content
AppRegistry.registerComponent('App', () => App)
export default createStackNavigator(
Home:
screen: HomeScreen,
,
,
initialRouteName: 'Home',
);
react-native react-navigation
I've build an app with a BottomTabNavigator
and createSwitchNavigator
.
If I declare my screen inside the MainTabNavigator
, the top header of my screens work as intended, but as soon as I import my screens (for example my HomeScreen
) I get a double header.
I've tried adding:
headerMode: 'none',
navigationOptions:
headerVisible: false,
To my StackNavigator
, but doesn't seem to have an effect.
I've tried looking at similar posted questions, but have not been set off into the right direction.
Is anyone else familiar with this problem and how to solve it?
App JS
import React from 'react';
import View, Text from 'react-native';
import createStackNavigator,createBottomTabNavigator from 'react-navigation';
import AppNavigator from './navigation/AppNavigator';
export default class App extends React.Component
render()
return <AppNavigator />;
App Navigator
import React from 'react';
import createSwitchNavigator from 'react-navigation';
import MainTabNavigator from './MainTabNavigator';
export default createSwitchNavigator(
Main: MainTabNavigator,
,
);
MainTabNavigator
import React from 'react';
import Button, Text, View from 'react-native';
import Ionicons from '@expo/vector-icons';
import createStackNavigator, createBottomTabNavigator from 'react-navigation';
import HomeScreen from '../screens/clubs/Home';
import DetailsScreen from '../screens/clubs/Details';
class SettingsScreen extends React.Component
static navigationOptions =
// title: ' Alpha',
header: null,
;
render()
return (
<View style= flex: 1, justifyContent: 'center', alignItems: 'center' >
<Text>Settings!</Text>
<Button
title="Go to Home"
onPress=() => this.props.navigation.navigate('Home')
/>
<Button
title="Go to Details"
onPress=() => this.props.navigation.navigate('Details')
/>
</View>
);
const HomeStack = createStackNavigator(
Home: screen: HomeScreen ,
Details: screen: DetailsScreen ,
);
const SettingsStack = createStackNavigator(
Settings: screen: SettingsScreen ,
Details: screen: DetailsScreen ,
);
export default createBottomTabNavigator(
Home: screen: HomeStack ,
Settings: screen: SettingsStack ,
,
navigationOptions: ( navigation ) => (
tabBarIcon: ( focused, tintColor ) =>
const routeName = navigation.state;
let iconName;
if (routeName === 'Home')
iconName = `ios-information-circle$focused ? '' : '-outline'`;
else if (routeName === 'Settings')
iconName = `ios-information-circle$focused ? '' : '-outline'`;
return <Ionicons name=iconName size=25 color=tintColor />;
,
),
tabBarOptions:
activeTintColor: '#DD016B',
inactiveTintColor: 'white',
tabStyle:
width: 100,
backgroundColor: 'black',
,
labelStyle:
color: 'white',
,
,
);
Home JS
import React, Component from 'react';
import
AppRegistry,
ListView,
View,
Text,
StyleSheet,
Image,
Button,
TouchableOpacity,
TextInput,
ScrollView,
Icon,
FlatList,
from 'react-native';
import createStackNavigator, from 'react-navigation';
export class HomeScreen extends Component
static navigationOptions =
// title: ' Alpha',
header: null,
;
....... App content
AppRegistry.registerComponent('App', () => App)
export default createStackNavigator(
Home:
screen: HomeScreen,
,
,
initialRouteName: 'Home',
);
react-native react-navigation
react-native react-navigation
edited Nov 15 '18 at 21:44
c-chavez
2,40221833
2,40221833
asked Nov 15 '18 at 20:08
SalmanSalman
69219
69219
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
In your MainTabNavigator
file, try this:
const HomeStack = createStackNavigator(
Home: screen: HomeScreen, navigationOptions: header: null ,
Details: screen: DetailsScreen, navigationOptions: header: null ,
);
Thanks this worked, weird tho since I have tried this before!
– Salman
Nov 16 '18 at 9:13
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53327183%2fswitch-navigator-two-headers%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
In your MainTabNavigator
file, try this:
const HomeStack = createStackNavigator(
Home: screen: HomeScreen, navigationOptions: header: null ,
Details: screen: DetailsScreen, navigationOptions: header: null ,
);
Thanks this worked, weird tho since I have tried this before!
– Salman
Nov 16 '18 at 9:13
add a comment |
In your MainTabNavigator
file, try this:
const HomeStack = createStackNavigator(
Home: screen: HomeScreen, navigationOptions: header: null ,
Details: screen: DetailsScreen, navigationOptions: header: null ,
);
Thanks this worked, weird tho since I have tried this before!
– Salman
Nov 16 '18 at 9:13
add a comment |
In your MainTabNavigator
file, try this:
const HomeStack = createStackNavigator(
Home: screen: HomeScreen, navigationOptions: header: null ,
Details: screen: DetailsScreen, navigationOptions: header: null ,
);
In your MainTabNavigator
file, try this:
const HomeStack = createStackNavigator(
Home: screen: HomeScreen, navigationOptions: header: null ,
Details: screen: DetailsScreen, navigationOptions: header: null ,
);
answered Nov 16 '18 at 4:11
Uzair A.Uzair A.
6121521
6121521
Thanks this worked, weird tho since I have tried this before!
– Salman
Nov 16 '18 at 9:13
add a comment |
Thanks this worked, weird tho since I have tried this before!
– Salman
Nov 16 '18 at 9:13
Thanks this worked, weird tho since I have tried this before!
– Salman
Nov 16 '18 at 9:13
Thanks this worked, weird tho since I have tried this before!
– Salman
Nov 16 '18 at 9:13
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53327183%2fswitch-navigator-two-headers%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown