Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function SwitchNavigator(props: Props) {
const { state, descriptors } = useNavigationBuilder<
TabNavigationState,
TabRouterOptions,
{},
{}
>(TabRouter, props);
return descriptors[state.routes[state.index].key].render();
}
function DrawerNavigator({
initialRouteName,
children,
screenOptions,
...rest
}: Props) {
const { state, descriptors, navigation } = useNavigationBuilder<
DrawerNavigationState,
DrawerRouterOptions,
DrawerNavigationOptions,
DrawerNavigationEventMap
>(DrawerRouter, {
initialRouteName,
children,
screenOptions,
});
return (
function StackNavigator({
initialRouteName,
children,
screenOptions,
...rest
}: Props) {
const { state, descriptors, navigation } = useNavigationBuilder<
StackNavigationState,
StackRouterOptions,
StackNavigationOptions,
StackNavigationEventMap
>(StackRouter, {
initialRouteName,
children,
screenOptions,
});
React.useEffect(
() =>
navigation.addListener &&
navigation.addListener('tabPress', (e: EventArg<'tabPress'>) => {
const isFocused = navigation.isFocused();
function MaterialBottomTabNavigator({
initialRouteName,
backBehavior,
children,
screenOptions,
...rest
}: Props) {
const { state, descriptors, navigation } = useNavigationBuilder<
TabNavigationState,
TabRouterOptions,
MaterialBottomTabNavigationOptions,
MaterialBottomTabNavigationEventMap
>(TabRouter, {
initialRouteName,
backBehavior,
children,
screenOptions,
});
return (
function BottomTabNavigator({
initialRouteName,
backBehavior,
children,
screenOptions,
...rest
}: Props) {
const { state, descriptors, navigation } = useNavigationBuilder<
TabNavigationState,
TabRouterOptions,
BottomTabNavigationOptions,
BottomTabNavigationEventMap
>(TabRouter, {
initialRouteName,
backBehavior,
children,
screenOptions,
});
return (
function MaterialTopTabNavigator({
initialRouteName,
backBehavior,
children,
screenOptions,
...rest
}: Props) {
const { state, descriptors, navigation } = useNavigationBuilder<
TabNavigationState,
TabRouterOptions,
MaterialTopTabNavigationOptions,
MaterialTopTabNavigationEventMap
>(TabRouter, {
initialRouteName,
backBehavior,
children,
screenOptions,
});
return (
function SimpleNavigator(
props: DefaultNavigatorOptions
) {
const { state, descriptors } = useNavigationBuilder(StackRouter, props);
const route = state.routes[state.index];
const { render, options, navigation } = descriptors[route.key];
return (
<>
{options.headerShown !== false &&
options.header &&
options.header({
navigation,
scene: { descriptor: descriptors[route.key] },
previous:
state.index === 0
? undefined
: { descriptor: descriptors[state.routes[state.index - 1].key] },
})}
{render()}
function NativeStackNavigator(props: NativeStackNavigatorProps) {
if (!screensEnabled()) {
throw new Error(
'Native stack is only available if React Native Screens is enabled.'
);
}
const { initialRouteName, children, screenOptions, ...rest } = props;
const { state, descriptors, navigation } = useNavigationBuilder<
StackNavigationState,
StackRouterOptions,
NativeStackNavigationOptions,
{}
>(StackRouter, {
initialRouteName,
children,
screenOptions,
});
React.useEffect(
() =>
navigation.addListener &&
navigation.addListener('tabPress', (e: EventArg<'tabPress'>) => {
const isFocused = navigation.isFocused();