From 83a235900f721a4a9af29630b48931ac8a156247 Mon Sep 17 00:00:00 2001 From: Artur Burlak Date: Sat, 21 Jun 2025 18:33:33 +0200 Subject: [PATCH] Fix TS issues for Screens and withProvider --- .../ReactNavigationDetailScreen.tsx | 26 +++++++++---------- .../components/ReactNavigationHomeScreen.tsx | 17 ++++++------ .../ReactNavigationModalDetailScreen.tsx | 20 +++++++------- .../ReactNavigationSettingsScreen.tsx | 17 ++++++------ example/src/components/withProvider.tsx | 4 ++- example/src/types/Navigation.tsx | 4 --- 6 files changed, 43 insertions(+), 45 deletions(-) diff --git a/example/src/components/ReactNavigationDetailScreen.tsx b/example/src/components/ReactNavigationDetailScreen.tsx index d77936d7..dcfcea37 100644 --- a/example/src/components/ReactNavigationDetailScreen.tsx +++ b/example/src/components/ReactNavigationDetailScreen.tsx @@ -1,29 +1,29 @@ import * as React from 'react'; import { Button, Text } from 'react-native'; -import type { ScreenProps } from '../types/Navigation'; +import type { Routes } from '../types/Navigation'; import { SafeAreaViewVisualizer } from './SafeAreaViewVisualizer'; +import { useNavigation } from '@react-navigation/native'; +import { NativeStackNavigationProp } from '@react-navigation/native-stack'; -export default function ReactNavigationDetailScreen({ - navigation, -}: ScreenProps<'Details'>) { - const isV5 = typeof navigation.setOptions === 'function'; +export default function ReactNavigationDetailScreen() { const [headerShown, setHeaderShown] = React.useState(true); + const { navigate, goBack, setOptions, push } = + useNavigation>(); + + const isV5 = typeof setOptions === 'function'; React.useLayoutEffect(() => { if (isV5) { - navigation.setOptions({ headerShown }); + setOptions({ headerShown }); } - }, [navigation, isV5, headerShown]); + }, [setOptions, isV5, headerShown]); return ( Details Screen -