Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Hide header #1534

Closed
saeropark opened this issue May 16, 2017 · 11 comments
Closed

How to Hide header #1534

saeropark opened this issue May 16, 2017 · 11 comments
Labels

Comments

@saeropark
Copy link

saeropark commented May 16, 2017

photo_2017-05-16_17-07-23

Hi as you can see I have 3 very ugly headers.

How it works is the main header "EVENTS & ANNOUNCEMENTS" is under a drawer navigator from sidebar.js

by clicking on each item drawer, it will open up a screen, and in this case a view with 2 tabs (the blue tabs) eventTabs.js

SO WHEN i click on each listitem, it will open up another screen with the header. currently. I have hidden the TITLE: PULSE EVENT header., but i was wondering is there a way to set "EVENTS & ANNOUNCEMENTS to the listitem title?

or

to hide sidebar.js header and enforce a the current screen's EventStack navigator header?

Inside ``eventTabs.js`:

const AnnStack = StackNavigator({
    List: {screen: EventList},
    Info: {screen: EventDetail},
    
} );

const EventTab = TabNavigator({
    Upcoming: { screen: AnnStack },
    Past: { screen: PastTab },
},
    { mode: 'modal' } // this is needed to make sure header is hidden on ios
);

const EventStack = StackNavigator({
    Home: {screen: EventTab},
});
@saeropark
Copy link
Author

saeropark commented May 16, 2017

I think my issue similar to #88 and #141

but my problem is between navigators in different files. Hopefully there is some help..

@bktoky
Copy link

bktoky commented May 16, 2017

static navigationOptions = {
header: null,
};

@saeropark
Copy link
Author

@bktoky i have done that to hide the TITLE: XXX header. however, i wish to either

  • replace it with EVENTS & ANNOUNCEMENTS header
  • hide EVENTS & ANNOUNCEMENTS header when i navigate into eventTabs.js

@xipgroc
Copy link

xipgroc commented May 19, 2017

have you tried headerMode: 'none' as option of StackNavigator?

@JanPeter
Copy link

JanPeter commented Jul 14, 2017

I'm using the StackNavigator and headerMode: 'none' does not work for me. At least if I configure it like the following:

export default class Onboarding extends Component {

  static navigationOptions = {
    headerMode: 'none'
  }

  ...
}

header: null works for me.

I think the documentation there is a little misleading as:

none - No header will be rendered.

means at least in my opinion that no header will be displayed. So it doesn't make any sense to render the grey block where the header would be placed. But furthermore:

header
React Element or a function that given HeaderProps returns a React Element, to display as a header. Setting to null hides header.

Clearly says that the header will be hidden.

@jaycee425
Copy link

jaycee425 commented Jul 17, 2017

is there a way to do it programmatically?
header: navigation.state.params.thanks === 'thanks' ? null : [what-to-put],
I want it to have just the normal component not a personalized one,, thank you :D


nevermind i just make the control on the header height and set it to 0 when i dont need it and then the null on hte header left and right if needed ...if there's an easier way im open ot suggestions

@JanPeter
Copy link

@jaycee425 You can do it programmatically with the following code:

static navigationOptions = ({ navigation }) => ({
  header: (navigation.state.params.thanks) => <HeaderView content={navigation.state.params.thanks} /> : null,
})

And then you can set the state params with this:

componentWillMount() {
  this.props.navigation.setParams({ thanks: "Something" });
}

Although I haven't tried the code myself and I'm not sure if something like the HeaderView is accessible for the public api in react-navigation and if there is a content property on that. But I think in an abstract way, this is how you set it programmatically.

@puelocesar
Copy link

puelocesar commented Aug 2, 2017

I want to hide the navigation bar when showing my searchBar, so I do the following:

if (navigation.state.params && navigation.state.params.showSearch) {
    return {
        header: null,
    }
}

This works fine on iOS, but on Android, I get a blank header above my UI. Any ideas?

@spencercarli
Copy link
Member

Hi! In an effort to get the hundreds of issues on this repo under control I'm closing issues tagged as questions. Please don't take this personally - it's simply something we need to do to get the issues to a manageable point. If you still have a question I encourage you to re-read the docs, ask on StackOverflow, or ask on the #react-navigation Reactiflux channel. Thank you!

@thebylito
Copy link

static navigationOptions = { header: null };

this works for me, "react-navigation": "^2.0.4"

@brentvatne
Copy link
Member

@react-navigation react-navigation locked and limited conversation to collaborators May 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

8 participants