From 3883c0307ae681f65bc4d7ff138a978fc6f7b1a1 Mon Sep 17 00:00:00 2001 From: xmflsct Date: Mon, 16 Jan 2023 14:20:36 +0100 Subject: [PATCH] Fix public page switching timeline not updating nav params --- src/screens/Tabs/Public/Root.tsx | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/screens/Tabs/Public/Root.tsx b/src/screens/Tabs/Public/Root.tsx index c20a4398..b24929c6 100644 --- a/src/screens/Tabs/Public/Root.tsx +++ b/src/screens/Tabs/Public/Root.tsx @@ -1,8 +1,7 @@ import { HeaderRight } from '@components/Header' import Timeline from '@components/Timeline' import SegmentedControl from '@react-native-community/segmented-control' -import { useNavigation } from '@react-navigation/native' -import { NativeStackNavigationProp, NativeStackScreenProps } from '@react-navigation/native-stack' +import { NativeStackScreenProps } from '@react-navigation/native-stack' import { TabPublicStackParamList } from '@utils/navigation/navigators' import { QueryKeyTimeline } from '@utils/queryHooks/timeline' import { getGlobalStorage, setGlobalStorage } from '@utils/storage/actions' @@ -14,12 +13,7 @@ import { Dimensions } from 'react-native' import { SceneMap, TabView } from 'react-native-tab-view' const Route = ({ route: { key: page } }: { route: any }) => { - const navigation = - useNavigation>() const queryKey: QueryKeyTimeline = ['Timeline', { page }] - useEffect(() => { - navigation.setParams({ queryKey }) - }, []) return } @@ -35,12 +29,11 @@ const Root: React.FC( Math.max( 0, - segments.findIndex(segment => segment === previousSegment) + segments.findIndex(segment => segment === getGlobalStorage.string('app.prev_public_segment')) ) ) const [routes] = useState([ @@ -48,6 +41,10 @@ const Root: React.FC { + const page = segments[segment] + page && navigation.setParams({ queryKey: ['Timeline', { page }] }) + }, [segment]) useEffect(() => { navigation.setOptions({