-
-
Notifications
You must be signed in to change notification settings - Fork 5k
/
createDrawerNavigator.tsx
59 lines (54 loc) · 1.24 KB
/
createDrawerNavigator.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import * as React from 'react';
import {
createNavigatorFactory,
useNavigationBuilder,
DefaultNavigatorOptions,
DrawerNavigationState,
DrawerRouterOptions,
DrawerRouter,
ParamListBase,
} from '@react-navigation/native';
import DrawerView from '../views/DrawerView';
import type {
DrawerNavigationOptions,
DrawerNavigationConfig,
DrawerNavigationEventMap,
} from '../types';
type Props = DefaultNavigatorOptions<DrawerNavigationOptions> &
DrawerRouterOptions &
DrawerNavigationConfig;
function DrawerNavigator({
initialRouteName,
openByDefault,
backBehavior,
children,
screenOptions,
...rest
}: Props) {
const { state, descriptors, navigation } = useNavigationBuilder<
DrawerNavigationState<ParamListBase>,
DrawerRouterOptions,
DrawerNavigationOptions,
DrawerNavigationEventMap
>(DrawerRouter, {
initialRouteName,
openByDefault,
backBehavior,
children,
screenOptions,
});
return (
<DrawerView
{...rest}
state={state}
descriptors={descriptors}
navigation={navigation}
/>
);
}
export default createNavigatorFactory<
DrawerNavigationState<ParamListBase>,
DrawerNavigationOptions,
DrawerNavigationEventMap,
typeof DrawerNavigator
>(DrawerNavigator);