React 导航抽屉的正确输入方式

问题描述 投票:0回答:1

输入 RNavigation 的正确方法是什么,目前我正在应用程序上执行此操作

export type DrawerNavigatorType = {
  Store: unknown;
  ImagesStudio: { images: string[] }; //
};

const Drawer = createDrawerNavigator();

const DrawerNavigator = () =>  (
    <Drawer.Navigator>
      <Drawer.Screen
        name="Store"
        component={StoreNavigator}
      />
      <Drawer.Screen
        name="ImagesStudio"
        component={ImageStudioScreen}
      />
    </Drawer.Navigator>
  );

在屏幕上

type Prop = DrawerScreenProps<DrawerNavigatorType, "ImagesStudio">;

但我不断

Type '({ navigation, route }: Prop) => React.JSX.Element' is not assignable to type 'ScreenComponentType<ParamListBase, "ImagesStudio"> | undefined'.
  Type '({ navigation, route }: Prop) => React.JSX.Element' is not assignable to type 'FunctionComponent<{}>'.
    Types of parameters '__0' and 'props' are incompatible.
      Type '{}' is missing the following properties from type 'Prop': navigation, routets(2322)
types.d.ts(318, 5): The expected type comes from property 'component' which is declared here on type 'IntrinsicAttributes & RouteConfig<ParamListBase, "ImagesStudio", DrawerNavigationState<ParamListBase>, DrawerNavigationOptions, DrawerNavigationEventMap>'

有人知道我做错了什么吗?

typescript react-navigation react-native-navigation react-navigation-drawer react-navigation-v6
1个回答
0
投票

通过更改修复

const Drawer = createDrawerNavigator();

const Drawer = createDrawerNavigator<DrawerNavigatorType>();
© www.soinside.com 2019 - 2024. All rights reserved.