mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-01-27 09:08:37 +08:00
Some compatibility adjustments for react-navigation bindings (#196)
This commit is contained in:
committed by
GitHub
parent
7c304a007f
commit
7d4bbb8f88
@@ -18,6 +18,13 @@ import {
|
||||
ScreenStackHeaderTitleView,
|
||||
} from 'react-native-screens';
|
||||
|
||||
function renderComponentOrThunk(componentOrThunk, props) {
|
||||
if (typeof componentOrThunk === 'function') {
|
||||
return componentOrThunk(pops);
|
||||
}
|
||||
return componentOrThunk;
|
||||
}
|
||||
|
||||
class StackView extends React.Component {
|
||||
_removeScene = route => {
|
||||
const { navigation } = this.props;
|
||||
@@ -90,7 +97,7 @@ class StackView extends React.Component {
|
||||
if (options.headerLeft !== undefined) {
|
||||
children.push(
|
||||
<ScreenStackHeaderLeftView key="left">
|
||||
{options.headerLeft({ scene })}
|
||||
{renderComponentOrThunk(options.headerLeft, { scene })}
|
||||
</ScreenStackHeaderLeftView>
|
||||
);
|
||||
} else if (options.headerBackImage !== undefined) {
|
||||
@@ -120,17 +127,21 @@ class StackView extends React.Component {
|
||||
}
|
||||
|
||||
if (options.headerTitle) {
|
||||
children.push(
|
||||
<ScreenStackHeaderTitleView key="title">
|
||||
{options.headerTitle({ scene })}
|
||||
</ScreenStackHeaderTitleView>
|
||||
);
|
||||
if (title === undefined && typeof options.headerTitle === 'string') {
|
||||
headerOptions.title = options.headerTitle;
|
||||
} else {
|
||||
children.push(
|
||||
<ScreenStackHeaderTitleView key="title">
|
||||
{renderComponentOrThunk(options.headerTitle, { scene })}
|
||||
</ScreenStackHeaderTitleView>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (options.headerRight) {
|
||||
children.push(
|
||||
<ScreenStackHeaderRightView key="right">
|
||||
{options.headerRight({ scene })}
|
||||
{renderComponentOrThunk(options.headerRight, { scene })}
|
||||
</ScreenStackHeaderRightView>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user