Skip to content
This repository was archived by the owner on Feb 25, 2020. It is now read-only.

Commit 92f0f69

Browse files
committed
fix: properly handle header title
1 parent 90a72fa commit 92f0f69

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

src/views/Header/Header.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import * as React from 'react';
22
import { StackActions } from 'react-navigation';
33
import HeaderSegment from './HeaderSegment';
4-
import { HeaderProps, HeaderTitleProps } from '../../types';
5-
import HeaderTitle from './HeaderTitle';
4+
import { HeaderProps } from '../../types';
65

76
export default class Header extends React.PureComponent<HeaderProps> {
87
render() {
@@ -46,11 +45,6 @@ export default class Header extends React.PureComponent<HeaderProps> {
4645
scene={scene}
4746
title={title}
4847
leftLabel={leftLabel}
49-
headerTitle={
50-
options.headerTitle === undefined
51-
? (props: HeaderTitleProps) => <HeaderTitle {...props} />
52-
: options.headerTitle
53-
}
5448
onGoBack={
5549
previous
5650
? () =>

src/views/Header/HeaderSegment.tsx

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
} from 'react-native';
99
import Animated from 'react-native-reanimated';
1010
import { SafeAreaContext, EdgeInsets } from 'react-native-safe-area-context';
11+
import HeaderTitle from './HeaderTitle';
1112
import HeaderBackButton from './HeaderBackButton';
1213
import HeaderBackground from './HeaderBackground';
1314
import memoize from '../../utils/memoize';
@@ -358,14 +359,22 @@ export default class HeaderSegment extends React.Component<Props, State> {
358359
titleContainerStyle,
359360
]}
360361
>
361-
{typeof headerTitle === 'function'
362-
? headerTitle({
363-
children: currentTitle,
364-
onLayout: this.handleTitleLayout,
365-
allowFontScaling: titleAllowFontScaling,
366-
style: [{ color: headerTintColor }, customTitleStyle],
367-
})
368-
: headerTitle}
362+
{typeof headerTitle === 'function' ? (
363+
headerTitle({
364+
children: currentTitle,
365+
onLayout: this.handleTitleLayout,
366+
allowFontScaling: titleAllowFontScaling,
367+
style: [{ color: headerTintColor }, customTitleStyle],
368+
})
369+
) : (
370+
<HeaderTitle
371+
onLayout={this.handleTitleLayout}
372+
allowFontScaling={titleAllowFontScaling}
373+
style={[{ color: headerTintColor }, customTitleStyle]}
374+
>
375+
{currentTitle}
376+
</HeaderTitle>
377+
)}
369378
</Animated.View>
370379
{right !== undefined ? (
371380
<Animated.View

0 commit comments

Comments
 (0)