From c4d7223115865474f09661cdbfee60a559f4b2c2 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Fri, 15 Mar 2024 18:19:09 +0000 Subject: fix(mobile): Scroll to the top when the main tab is clicked --- apps/mobile/components/bookmarks/BookmarkList.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'apps/mobile/components') diff --git a/apps/mobile/components/bookmarks/BookmarkList.tsx b/apps/mobile/components/bookmarks/BookmarkList.tsx index e3c2bdb1..48272fb3 100644 --- a/apps/mobile/components/bookmarks/BookmarkList.tsx +++ b/apps/mobile/components/bookmarks/BookmarkList.tsx @@ -1,10 +1,11 @@ -import { useEffect, useState } from "react"; +import { useEffect, useRef, useState } from "react"; import { Text, View, Keyboard } from "react-native"; import Animated, { LinearTransition } from "react-native-reanimated"; import { api } from "@/lib/trpc"; import FullPageSpinner from "../ui/FullPageSpinner"; import BookmarkCard from "./BookmarkCard"; +import { useScrollToTop } from '@react-navigation/native'; export default function BookmarkList({ favourited, @@ -17,6 +18,8 @@ export default function BookmarkList({ }) { const apiUtils = api.useUtils(); const [refreshing, setRefreshing] = useState(false); + const flatListRef = useRef(null); + useScrollToTop(flatListRef); const { data, isPending, isPlaceholderData } = api.bookmarks.getBookmarks.useQuery({ favourited, @@ -39,6 +42,7 @@ export default function BookmarkList({ return (