Switch Navigator Two headers










0















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?



Double header



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',
);









share|improve this question




























    0















    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?



    Double header



    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',
    );









    share|improve this question


























      0












      0








      0








      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?



      Double header



      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',
      );









      share|improve this question
















      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?



      Double header



      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 15 '18 at 21:44









      c-chavez

      2,50121935




      2,50121935










      asked Nov 15 '18 at 20:08









      SalmanSalman

      74219




      74219






















          1 Answer
          1






          active

          oldest

          votes


















          1














          In your MainTabNavigator file, try this:



          const HomeStack = createStackNavigator(
          Home: screen: HomeScreen, navigationOptions: header: null ,
          Details: screen: DetailsScreen, navigationOptions: header: null ,
          );





          share|improve this answer























          • Thanks this worked, weird tho since I have tried this before!

            – Salman
            Nov 16 '18 at 9:13











          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
          );



          );













          draft saved

          draft discarded


















          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









          1














          In your MainTabNavigator file, try this:



          const HomeStack = createStackNavigator(
          Home: screen: HomeScreen, navigationOptions: header: null ,
          Details: screen: DetailsScreen, navigationOptions: header: null ,
          );





          share|improve this answer























          • Thanks this worked, weird tho since I have tried this before!

            – Salman
            Nov 16 '18 at 9:13















          1














          In your MainTabNavigator file, try this:



          const HomeStack = createStackNavigator(
          Home: screen: HomeScreen, navigationOptions: header: null ,
          Details: screen: DetailsScreen, navigationOptions: header: null ,
          );





          share|improve this answer























          • Thanks this worked, weird tho since I have tried this before!

            – Salman
            Nov 16 '18 at 9:13













          1












          1








          1







          In your MainTabNavigator file, try this:



          const HomeStack = createStackNavigator(
          Home: screen: HomeScreen, navigationOptions: header: null ,
          Details: screen: DetailsScreen, navigationOptions: header: null ,
          );





          share|improve this answer













          In your MainTabNavigator file, try this:



          const HomeStack = createStackNavigator(
          Home: screen: HomeScreen, navigationOptions: header: null ,
          Details: screen: DetailsScreen, navigationOptions: header: null ,
          );






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 16 '18 at 4:11









          Uzair A.Uzair A.

          5191525




          5191525












          • 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





          Thanks this worked, weird tho since I have tried this before!

          – Salman
          Nov 16 '18 at 9:13



















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          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





















































          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







          這個網誌中的熱門文章

          How to read a connectionString WITH PROVIDER in .NET Core?

          In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

          Museum of Modern and Contemporary Art of Trento and Rovereto