简体   繁体   English

UI Kitten 的 Top Navigation 组件如何在 React Native Stack Navigator 中用作自定义 header

[英]How can Top Navigation component from UI Kitten can be used in React Native Stack Navigator as a custom header

I Have a custom header component designed using UI Kitten "Top Navigation" component (link below to examples) i would like to use that as a header on main page instead of the header Stack Navigator provides我有一个自定义 header 组件使用 UI Kitten“顶部导航”组件设计(链接下面的示例)我想将其用作主页上的 header 而不是 Z099FB995346F31C749F6E40DB0F9

https://akveo.github.io/react-native-ui-kitten/docs/components/top-navigation/overview#topnavigationaction https://akveo.github.io/react-native-ui-kitten/docs/components/top-navigation/overview#topnavigationaction

lets say use custom "Top Navigation" component called AppHeader in NotificationScreen假设在NotificationScreen中使用名为AppHeader的自定义“顶部导航”组件

import React from 'react';
import {createStackNavigator} from '@react-navigation/stack';

import routes from './routes';
import AppHeader from '../components/AppHeader';
import NotificationScreen from '../screens/notification/NotificationScreen';
import UserProfileScreen from '../screens/userProfile/UserProfileScreen';

const {Navigator, Screen} = createStackNavigator();

const StackNavigatorPage = () => (
  <Navigator>
    <Screen name={routes.NOTIFICATION_SCREEN} component={NotificationScreen} />
    <Screen name={routes.USER_PROFILE_SCREEN} component={UserProfileScreen} />
  </Navigator>
);

export default StackNavigatorPage;

i figured it out and decided to leave the question and answer here in case someone might find this useful.我想通了,决定把问题和答案留在这里,以防有人发现这很有用。 Please let me know if this helped you as well如果这对您也有帮助,请告诉我

import React from 'react';
import {createStackNavigator} from '@react-navigation/stack';

import routes from './routes';
import AppHeader from '../components/AppHeader';
import NotificationScreen from '../screens/notification/NotificationScreen';
import UserProfileScreen from '../screens/userProfile/UserProfileScreen';
import HomeScreen from '../screens/dashboard/HomeScreen';

const {Navigator, Screen} = createStackNavigator();

const StackNavigatorPage = () => (
  <Navigator>
    <Screen
      name={routes.HOME_SCREEN}
      component={HomeScreen}
      options={({navigation}) => {
        return {
          header: () => <AppHeader navigation={navigation} />,
        };
      }}
    />
    <Screen name={routes.NOTIFICATION_SCREEN} component={NotificationScreen} />
    <Screen name={routes.USER_PROFILE_SCREEN} component={UserProfileScreen} />
  </Navigator>
);

export default StackNavigatorPage;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 反应本机导航堆栈导航器 header 未固定在 web 的顶部 - React native navigation stack navigator header not fixed at top for web React Navigation 5 - 带有自定义标题的本机堆栈导航器,带有搜索栏 - React Navigation 5 - Native Stack Navigator with custom header which has a searchbar 从堆栈导航器反应本机隐藏顶部导航 - React Native hide top navigation from stack navigator 从 React Native 中的 Stack Navigator 顶部删除标题 - Remove Header from top of Stack Navigator in React Native 如何在React Native Navigation v2中更新自定义顶部栏标题组件? - How can I update a custom top bar title component in React Native Navigation v2? 在 React-Native 中使用 Navigator 组件自定义导航 - Custom navigation with Navigator component in React-Native 使用 React Navigation,如何强制抽屉导航器弹出到堆栈顶部? - Using React Navigation, how can I force the drawer navigator to pop to the top of the stack? 我如何向在本机中具有堆栈导航的抽屉式导航器项目添加图标 - how can i add icons to drawer navigator items that have stack navigation in react native 如何在 React-Native-Navigation v5 中为嵌套的 Stack-Navigator 设置默认屏幕? - How can I set a default screen for a nested Stack-Navigator in React-Native-Navigation v5? 无法在导航器的标题中设置自定义字体样式(React Navigation 4) - Can not set custom font style in header of navigator (React Navigation 4)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM