0

I'm facing a little problem with the header included with the stackNavigator in react-native.

i'v got two views that i'm navigating between, Skatebay and Profile. When I use the stackNavigator it add's a top-bar "header" to the Skatebay view, how can i remove it, if not possible, can i style it to look like the header i've already created?

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  TouchableHighlight,
  Image,
  ScrollView,
  Button,
} from 'react-native';
import { StackNavigator } from 'react-navigation';
import s from './styles/main.js';

class skatebay extends React.Component{

  render(){
    const { navigate } = this.props.navigation;
    return (

  <View style={s.container}>

      <View style={s.toolbar}>
        <TouchableHighlight style={s.toolbarButton} onPress={() => navigate('Profile')}
          title="Profile">
          <Image style={s.toolIcon} source={require('./gfx/profile.png')}/>
        </TouchableHighlight>

        <TouchableHighlight style={s.toolbarTitle} onPress={alert}>
          <Image style={s.logo} source={require('./gfx/logos.png')}/>
        </TouchableHighlight>

        <TouchableHighlight style={s.toolbarButton} onPress={alert}>
          <Image style={s.toolIcon} source={require('./gfx/settings.png')}/>
        </TouchableHighlight>
      </View>

      </View>
    );
    }
}


Profile view

class ProfileScreen extends React.Component {
    static navigationOptions = {
        title: 'Profile',
    };
render() {
    return (
      <View>
        <Text>profile</Text>
      </View>
    );
  }
}


const skatebayApp = StackNavigator({
  Main: {screen: skatebay},
  Profile: {screen: ProfileScreen}
});

AppRegistry.registerComponent('skatebayApp', () => skatebayApp);

I'm talking about the blue/gray header above the white header i've created.

enter image description here

1 Answer 1

2

If you dont want the default header of StackNavigator, you can pass none to StackNavigatorConfig https://reactnavigation.org/docs/navigators/stack#StackNavigatorConfig

const skatebayApp = StackNavigator({
  Main: {screen: skatebay},
  Profile: {screen: ProfileScreen}
}, {
  headerMode: 'none'
});
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot, can't belive it was so hard to find. You saved my day

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.