Created
February 10, 2024 12:14
Revisions
-
ozcanzaferayan created this gist
Feb 10, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ import { useNavigation } from "expo-router"; import { useEffect } from "react"; import { FlatList } from "react-native"; export const useTabPressScroll = <T>(ref: React.RefObject<FlatList<T>>) => { const navigation = useNavigation(); useEffect(() => { // @ts-expect-error tabPress is not in the type const unsub = navigation.addListener("tabPress", (evt) => { if (navigation.isFocused()) { ref.current?.scrollToOffset({ offset: 0, animated: true, }); } }); return unsub; }, [navigation]); };