mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-04-24 04:25:34 +08:00
Add header.left property (#29)
* Add header.left property * Add docs * Updates * Update * Remove unused param * Update' * fix * Make sure to guard undefined defaultProps
This commit is contained in:
committed by
Mateusz Zatorski
parent
c34a6d5682
commit
7c0fcc6cf5
@@ -113,6 +113,11 @@ export type HeaderConfig = {
|
||||
*/
|
||||
right?: React.Element<*>,
|
||||
|
||||
/**
|
||||
* Renders a custom left component
|
||||
*/
|
||||
left?: React.Element<*>,
|
||||
|
||||
/**
|
||||
* Style passed into navigation bar container
|
||||
*/
|
||||
|
||||
@@ -201,13 +201,27 @@ class CardStack extends React.Component<DefaultProps, Props, void> {
|
||||
style={header.style}
|
||||
mode={headerMode}
|
||||
onNavigateBack={() => this.props.navigation.goBack(null)}
|
||||
renderLeftComponent={(props) => {
|
||||
const navigation = this._getChildNavigation(props.scene);
|
||||
const header = this.props.router.getScreenConfig(navigation, 'header');
|
||||
if (header && header.left) {
|
||||
return header.left;
|
||||
}
|
||||
const { renderLeftComponent } = this.props.headerComponent.defaultProps || {};
|
||||
if (typeof renderLeftComponent === 'function') {
|
||||
return renderLeftComponent(props);
|
||||
}
|
||||
return null;
|
||||
}}
|
||||
renderRightComponent={({ scene }) => {
|
||||
const navigation = this._getChildNavigation(scene);
|
||||
const header = this.props.router.getScreenConfig(navigation, 'header');
|
||||
const right = header && header.right;
|
||||
return right;
|
||||
if (header && header.right) {
|
||||
return header.right;
|
||||
}
|
||||
return null;
|
||||
}}
|
||||
renderTitleComponent={({ scene, navigationState }) => {
|
||||
renderTitleComponent={({ scene }) => {
|
||||
const navigation = this._getChildNavigation(scene);
|
||||
const header = this.props.router.getScreenConfig(navigation, 'header');
|
||||
let title = null;
|
||||
|
||||
Reference in New Issue
Block a user