最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to remove app bar from in react native? - Stack Overflow

programmeradmin1浏览0评论

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 './ponents/homeScreen';
const RootStack = createStackNavigator(
    {
      Home: HomeScreen,
    //   Details: DetailsScreen,
    },
    {
      initialRouteName: 'Home',
    },
    { headerMode: 'none' },
  );


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

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 './ponents/homeScreen';
const RootStack = createStackNavigator(
    {
      Home: HomeScreen,
    //   Details: DetailsScreen,
    },
    {
      initialRouteName: 'Home',
    },
    { headerMode: 'none' },
  );


export default class App extends Component {
  render() {
    return ( 
      <RootStack/>
    );
  }
}
Share Improve this question edited Sep 22, 2018 at 18:42 Samuel Hulla 7,1398 gold badges42 silver badges79 bronze badges asked Sep 22, 2018 at 17:32 AndrewAndrew 8051 gold badge10 silver badges13 bronze badges 1
  • 1 check stackoverflow./questions/46065819/… – kj007 Commented Sep 22, 2018 at 17:36
Add a ment  | 

2 Answers 2

Reset to default 6

People ing 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.

Simply do this and it will remove the appbar

class YourClass extends React.PureComponent {

static navigationOptions = {
    header: null,
  }
发布评论

评论列表(0)

  1. 暂无评论