简体   繁体   中英

How to remove app bar from in react native?

I am new to react native.

I am trying to create two screens. My issue is that I don't want app bar on the first screen but I want app bar on the second screen as I need to go back.

am going to the next screen by pressing the card from the first screen and am using createStackNavigator for navigation.

import React, { Component } from 'react';
import { createStackNavigator } from 'react-navigation';
import HomeScreen from './components/homeScreen';
const RootStack = createStackNavigator(
    {
      Home: HomeScreen,
    //   Details: DetailsScreen,
    },
    {
      initialRouteName: 'Home',
    },
    { headerMode: 'none' },
  );


export default class App extends Component {
  render() {
    return ( 
      <RootStack/>
    );
  }
}

Simply do this and it will remove the appbar

class YourClass extends React.PureComponent {

static navigationOptions = {
    header: null,
  }

People coming here from using @react-navigation with React Native or Expo (Tab navigation in this case):

    <NavigationContainer>
      <Tab.Navigator
        screenOptions={{ headerShown: false }}

If you want to conditionally apply it just hook "headerShown" to a state variable.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM