Skip to content

Instantly share code, notes, and snippets.

@dantman
Created February 28, 2018 22:38
Show Gist options
  • Save dantman/b11354378402e0f611204deda0c610fe to your computer and use it in GitHub Desktop.
Save dantman/b11354378402e0f611204deda0c610fe to your computer and use it in GitHub Desktop.
Overriding the left header button in a custom header
'use strict';
import React, {PureComponent} from 'react';
import {Header} from 'react-navigation';
export default class NavigationHeader extends PureComponent {
getScreenDetails = (screen, ...args) => {
const screenDetails = this.props.getScreenDetails(screen, ...args);
const {navigate, goBack} = screenDetails.navigation;
return {
...screenDetails,
options: {
...screenDetails.options,
headerLeft: (
screenDetails.options.headerLeft ||
screen.index > 0
? <MyCustomBackButton {...} />
: <MyCustomDrawerMenu {...} />,
},
};
}
render() {
return (
<Header
{...this.props}
getScreenDetails={this.getScreenDetails} />
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment