Skip to content

Commit

Permalink
fix leak (Memmy-App#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
gkasdorf authored Jun 23, 2023
1 parent 782f6d2 commit b9aaea4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
10 changes: 6 additions & 4 deletions Stack.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint react/no-unstable-nested-components: 0 */

import React, { useState } from "react";
import React from "react";
import { DarkTheme, NavigationContainer } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
Expand All @@ -20,13 +20,11 @@ import CreateAccountScreen from "./components/screens/onboarding/CreateAccountSc
import BookmarksScreen from "./components/screens/userProfile/BookmarksScreen";
import UserProfileScreen from "./components/screens/userProfile/UserProfileScreen";
import SubscriptionsScreen from "./components/screens/userProfile/SubscriptionsScreen";
import { useAppDispatch, useAppSelector } from "./store";
import { loadSettings } from "./slices/settings/settingsActions";
import { useAppSelector } from "./store";
import {
selectAccounts,
selectAccountsLoaded,
} from "./slices/accounts/accountsSlice";
import { loadAccounts } from "./slices/accounts/accountsActions";
import BlockedCommunitiesScreen from "./components/screens/userProfile/BlockedCommunitiesScreen";
import ViewAccountsScreen from "./components/screens/settings/ViewAccountsScreen";
import CommunityAboutScreen from "./components/screens/feeds/CommunityAboutScreen";
Expand All @@ -47,6 +45,7 @@ function FeedStackScreen() {
headerTitleStyle: {
color: theme.colors.app.primaryText,
},
freezeOnBlur: true,
}}
>
<FeedStack.Group>
Expand Down Expand Up @@ -110,6 +109,7 @@ function ProfileStackScreen() {
headerTitleStyle: {
color: theme.colors.app.primaryText,
},
freezeOnBlur: true,
}}
>
<ProfileStack.Screen
Expand Down Expand Up @@ -147,6 +147,7 @@ function SearchStackScreen() {
headerTitleStyle: {
color: theme.colors.app.nativeHeaderTitle,
},
freezeOnBlur: true,
}}
>
<SearchStack.Group>
Expand Down Expand Up @@ -257,6 +258,7 @@ function Tabs() {
backgroundColor: theme.colors.app.nativeHeader,
},
tabBarLabel: "Feed",
freezeOnBlur: true,
}}
>
<Tab.Screen
Expand Down
11 changes: 4 additions & 7 deletions components/hooks/post/postHooks.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import React, { useEffect, useRef, useState } from "react";
import {
CommentSortType,
CommentView,
ListingType,
PostView,
} from "lemmy-js-client";
import React, { useCallback, useEffect, useRef, useState } from "react";
import { CommentView, PostView } from "lemmy-js-client";
import { useToast } from "native-base";
import { useFocusEffect } from "@react-navigation/native";
import { useAppDispatch, useAppSelector } from "../../../store";
import { selectPost } from "../../../slices/post/postSlice";
import { lemmyAuthToken, lemmyInstance } from "../../../lemmy/LemmyInstance";
Expand Down Expand Up @@ -52,6 +48,7 @@ const usePost = (): UsePost => {
const [bookmarked, setBookmarked] = useState<boolean>(
bookmarks?.findIndex((b) => b.postId === currentPost.post.id) !== -1
);

const recycled = useRef({});

// Other Hooks
Expand Down
14 changes: 12 additions & 2 deletions components/screens/post/PostScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useEffect } from "react";
import React, { useCallback, useEffect, useState } from "react";

import {
Center,
Expand All @@ -11,7 +11,7 @@ import {
} from "native-base";
import { RefreshControl } from "react-native";
// eslint-disable-next-line import/no-extraneous-dependencies
import { useNavigation } from "@react-navigation/native";
import { useFocusEffect, useNavigation } from "@react-navigation/native";
import { NativeStackNavigationProp } from "@react-navigation/native-stack";
import { FlashList } from "@shopify/flash-list";
import { IconClockHour5, IconMessageCircle } from "tabler-icons-react-native";
Expand Down Expand Up @@ -39,6 +39,16 @@ function PostScreen() {
}`,
});
}, []);
//
// useFocusEffect(
// useCallback(() => {
// setShouldRender(true);
//
// return () => {
// setShouldRender(false);
// };
// }, [])
// );

const commentItem = useCallback(
({ item }) => (
Expand Down

0 comments on commit b9aaea4

Please sign in to comment.