反应导航,无法将标题传递给标题

时间:2019-05-17 08:57:04

标签: javascript react-native react-navigation

我在标题中看不到标题:

const withHeader = (
    screen: Function,
    routeName: string,
    Header
): StackNavigator =>
    createStackNavigator({
        [routeName]: {
            screen,
            navigationOptions: ({ navigation, routeName }) => ({
                header: props => <Header {...props} />,
                title: routeName,
                headerMode: "screen",
                layoutPreset: "right"
            })
        }
    });

this.props不包含标题道具。

如何将标题传递给标题?

1 个答案:

答案 0 :(得分:1)

您可以在班级/屏幕中使用static navigationOptions

class TargetScreen extends React.Component {
  static navigationOptions = {
    title: 'Your Title',
  };

  /* render function, etc */
}