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.
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'
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.