mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-04-29 12:55:21 +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,
|
ScreenStackHeaderTitleView,
|
||||||
} from 'react-native-screens';
|
} from 'react-native-screens';
|
||||||
|
|
||||||
|
function renderComponentOrThunk(componentOrThunk, props) {
|
||||||
|
if (typeof componentOrThunk === 'function') {
|
||||||
|
return componentOrThunk(pops);
|
||||||
|
}
|
||||||
|
return componentOrThunk;
|
||||||
|
}
|
||||||
|
|
||||||
class StackView extends React.Component {
|
class StackView extends React.Component {
|
||||||
_removeScene = route => {
|
_removeScene = route => {
|
||||||
const { navigation } = this.props;
|
const { navigation } = this.props;
|
||||||
@@ -90,7 +97,7 @@ class StackView extends React.Component {
|
|||||||
if (options.headerLeft !== undefined) {
|
if (options.headerLeft !== undefined) {
|
||||||
children.push(
|
children.push(
|
||||||
<ScreenStackHeaderLeftView key="left">
|
<ScreenStackHeaderLeftView key="left">
|
||||||
{options.headerLeft({ scene })}
|
{renderComponentOrThunk(options.headerLeft, { scene })}
|
||||||
</ScreenStackHeaderLeftView>
|
</ScreenStackHeaderLeftView>
|
||||||
);
|
);
|
||||||
} else if (options.headerBackImage !== undefined) {
|
} else if (options.headerBackImage !== undefined) {
|
||||||
@@ -120,17 +127,21 @@ class StackView extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (options.headerTitle) {
|
if (options.headerTitle) {
|
||||||
children.push(
|
if (title === undefined && typeof options.headerTitle === 'string') {
|
||||||
<ScreenStackHeaderTitleView key="title">
|
headerOptions.title = options.headerTitle;
|
||||||
{options.headerTitle({ scene })}
|
} else {
|
||||||
</ScreenStackHeaderTitleView>
|
children.push(
|
||||||
);
|
<ScreenStackHeaderTitleView key="title">
|
||||||
|
{renderComponentOrThunk(options.headerTitle, { scene })}
|
||||||
|
</ScreenStackHeaderTitleView>
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.headerRight) {
|
if (options.headerRight) {
|
||||||
children.push(
|
children.push(
|
||||||
<ScreenStackHeaderRightView key="right">
|
<ScreenStackHeaderRightView key="right">
|
||||||
{options.headerRight({ scene })}
|
{renderComponentOrThunk(options.headerRight, { scene })}
|
||||||
</ScreenStackHeaderRightView>
|
</ScreenStackHeaderRightView>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user