如何在带有react-navigation的标题中有多个按钮?

时间:2022-08-22 20:21:04

How can i put All and Favorites button in the header while using react-navigation?

如何在使用react-navigation时将All和Favorites按钮放在标题中?

如何在带有react-navigation的标题中有多个按钮?

1 个解决方案

#1


1  

You can use headerTitle prop to render any custom component to use in your header.

您可以使用headerTitle prop来呈现要在标头中使用的任何自定义组件。

headerTitle

headerTitle

String or React Element used by the header. Defaults to scene title

标头使用的字符串或反应元素。默认为场景标题

export const SimpleApp = StackNavigator({
  Home: {
    screen: HomeScreen,
    navigationOptions: {
      headerTitle: <MyCustomComponent />
    }
  },
  Profile: { screen: Profile }
});

#1


1  

You can use headerTitle prop to render any custom component to use in your header.

您可以使用headerTitle prop来呈现要在标头中使用的任何自定义组件。

headerTitle

headerTitle

String or React Element used by the header. Defaults to scene title

标头使用的字符串或反应元素。默认为场景标题

export const SimpleApp = StackNavigator({
  Home: {
    screen: HomeScreen,
    navigationOptions: {
      headerTitle: <MyCustomComponent />
    }
  },
  Profile: { screen: Profile }
});