Skip to content

Commit

Permalink
fix: tags not showing data on load
Browse files Browse the repository at this point in the history
  • Loading branch information
MuhammedKpln committed Aug 19, 2024
1 parent 40f69dd commit d70e329
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
21 changes: 12 additions & 9 deletions app/(app)/(tabs)/tags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { useAuthStore } from '@lib/store/auth.store';
import { useSuspenseQuery } from '@tanstack/react-query';
import { Link } from 'expo-router';
import React, { Suspense, useCallback } from 'react';
import { FlatList, RefreshControl } from 'react-native';
import { Spinner } from 'tamagui';
import { FlatList, Pressable, RefreshControl } from 'react-native';
import { Spinner, YStack } from 'tamagui';

export default function TagsScreen() {
const user = useAuthStore((state) => state.user);
Expand All @@ -30,13 +30,15 @@ export default function TagsScreen() {
}
}}
>
<TagCard
created_at={item.created_at}
isActive={item.isActive}
name={item.name!}
note={item.note!}
key={item.id}
/>
<Pressable>
<TagCard
created_at={item.created_at}
isActive={item.isActive}
name={item.name!}
note={item.note!}
key={item.id}
/>
</Pressable>
</Link>
);
}, []);
Expand Down Expand Up @@ -64,6 +66,7 @@ export default function TagsScreen() {
}
data={queryTags.data}
ListEmptyComponent={emptyBlock}
ItemSeparatorComponent={() => <YStack my="$2" />}
renderItem={renderItem}
/>
</Screen>
Expand Down
5 changes: 2 additions & 3 deletions lib/modules/tags/edit_tag.module.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export default function EditTagModule({ tagUid }: IProps) {
});

queryClient.setQueryData<ITag[]>([QueryKeys.Tags, user?.id], (v) => {
console.log(v);
if (v && v.length > 0) {
const updatedState = produce(v, (draft) => {
const index = draft.findIndex((e) => e.id === tagUid);
Expand All @@ -82,15 +81,15 @@ export default function EditTagModule({ tagUid }: IProps) {
setValue('isActive', tagQuery.data?.isActive ?? undefined);
setValue('note', tagQuery.data?.note ?? undefined);
}
}, [tagQuery.data]);
}, [tagQuery]);

useLayoutEffect(() => {
if (tagQuery.isSuccess) {
navigation.setOptions({
title: tagQuery.data!.name
});
}
}, [tagQuery.data]);
}, [tagQuery]);

const onSubmitForm = useCallback(async (inputs: EditTagFormTypes) => {
try {
Expand Down

0 comments on commit d70e329

Please sign in to comment.