From 92f0f6948f0818c228542c18de127072a73e9e93 Mon Sep 17 00:00:00 2001 From: "satyajit.happy" Date: Wed, 16 Oct 2019 15:23:24 +0200 Subject: [PATCH] fix: properly handle header title --- src/views/Header/Header.tsx | 8 +------- src/views/Header/HeaderSegment.tsx | 25 +++++++++++++++++-------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/views/Header/Header.tsx b/src/views/Header/Header.tsx index 67808a943..711c8c3ae 100644 --- a/src/views/Header/Header.tsx +++ b/src/views/Header/Header.tsx @@ -1,8 +1,7 @@ import * as React from 'react'; import { StackActions } from 'react-navigation'; import HeaderSegment from './HeaderSegment'; -import { HeaderProps, HeaderTitleProps } from '../../types'; -import HeaderTitle from './HeaderTitle'; +import { HeaderProps } from '../../types'; export default class Header extends React.PureComponent { render() { @@ -46,11 +45,6 @@ export default class Header extends React.PureComponent { scene={scene} title={title} leftLabel={leftLabel} - headerTitle={ - options.headerTitle === undefined - ? (props: HeaderTitleProps) => - : options.headerTitle - } onGoBack={ previous ? () => diff --git a/src/views/Header/HeaderSegment.tsx b/src/views/Header/HeaderSegment.tsx index a1ee88114..f39530596 100644 --- a/src/views/Header/HeaderSegment.tsx +++ b/src/views/Header/HeaderSegment.tsx @@ -8,6 +8,7 @@ import { } from 'react-native'; import Animated from 'react-native-reanimated'; import { SafeAreaContext, EdgeInsets } from 'react-native-safe-area-context'; +import HeaderTitle from './HeaderTitle'; import HeaderBackButton from './HeaderBackButton'; import HeaderBackground from './HeaderBackground'; import memoize from '../../utils/memoize'; @@ -358,14 +359,22 @@ export default class HeaderSegment extends React.Component { titleContainerStyle, ]} > - {typeof headerTitle === 'function' - ? headerTitle({ - children: currentTitle, - onLayout: this.handleTitleLayout, - allowFontScaling: titleAllowFontScaling, - style: [{ color: headerTintColor }, customTitleStyle], - }) - : headerTitle} + {typeof headerTitle === 'function' ? ( + headerTitle({ + children: currentTitle, + onLayout: this.handleTitleLayout, + allowFontScaling: titleAllowFontScaling, + style: [{ color: headerTintColor }, customTitleStyle], + }) + ) : ( + + {currentTitle} + + )} {right !== undefined ? (