输入 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>'
有人知道我做错了什么吗?
通过更改修复
const Drawer = createDrawerNavigator();
到
const Drawer = createDrawerNavigator<DrawerNavigatorType>();