Skip to content

Commit 7f7bab4

Browse files
author
tfomkin
committed
chore: replaced useFocusEffect with useIsFocused
1 parent 37d54e2 commit 7f7bab4

1 file changed

Lines changed: 3 additions & 15 deletions

File tree

libs/mobile/chat/features/menu-list/src/lib/component.tsx

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { useIsFocused } from '@react-navigation/native';
12
import { useTranslation } from '@ronas-it/react-native-common-modules/i18n';
2-
import { useFocusEffect } from 'expo-router';
33
import { ReactElement, useCallback, useEffect, useRef, useState } from 'react';
44
import {
55
ChatActionsMenuSheet,
@@ -38,7 +38,7 @@ export function ChatMenuList({
3838
}: ChatMenuListProps): ReactElement {
3939
const translate = useTranslation('CHAT.CHAT_MENU_LIST');
4040
const chatActionsSheetRef = useRef<ChatActionsMenuSheetMethods>(null);
41-
const isScreenFocusedRef = useRef(false);
41+
const isFocused = useIsFocused();
4242

4343
const [isFirstLoading, setIsFirstLoading] = useState<boolean>(true);
4444

@@ -76,16 +76,6 @@ export function ChatMenuList({
7676
}
7777
}, [isFirstLoading, isRefetching]);
7878

79-
useFocusEffect(
80-
useCallback(() => {
81-
isScreenFocusedRef.current = true;
82-
83-
return () => {
84-
isScreenFocusedRef.current = false;
85-
};
86-
}, []),
87-
);
88-
8979
const renderItem = useCallback(
9080
({ item }: { item: ChatListItem }) => (
9181
<ChatListRow
@@ -112,9 +102,7 @@ export function ChatMenuList({
112102
renderItem={renderItem}
113103
transformSectionTitle={transformSectionTitle}
114104
onEndReached={fetchNextPage}
115-
refreshControl={
116-
<AppRefreshControl onRefresh={refetch} refreshing={isScreenFocusedRef.current && isRefetching} />
117-
}
105+
refreshControl={<AppRefreshControl onRefresh={refetch} refreshing={isFocused && isRefetching} />}
118106
ListHeaderComponent={
119107
<View>
120108
{isFeatureEnabled(FeatureID.CHAT_FOLDERS) && (

0 commit comments

Comments
 (0)