From 0d1478decdc03c7a2336547a8e7856be66ca5ecf Mon Sep 17 00:00:00 2001 From: franco sanchez Date: Fri, 3 Nov 2023 11:23:00 -0300 Subject: [PATCH] chore: minor changes --- src/components/cards/MoreBooks.tsx | 9 --------- src/components/cards/RelatedBooks.tsx | 1 - src/hooks/useRefetchLocation.tsx | 10 +++++----- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/components/cards/MoreBooks.tsx b/src/components/cards/MoreBooks.tsx index 53c654b..641e3f6 100644 --- a/src/components/cards/MoreBooks.tsx +++ b/src/components/cards/MoreBooks.tsx @@ -10,21 +10,12 @@ export default function MoreBooks({ currentBookId }: ReleatedBooksType) { const { data, refetch } = useMoreBooks(); const moreBooks = useRefetchLocation(currentBookId, data, refetch); - // const moreBooks = data.filter((book: any) => { - // if (book.pathUrl === currentBookId) { - // refetch(); - // } - - // return book.pathUrl !== currentBookId; - // }); - return ( <> {moreBooks.map(({ id, title, authors, pathUrl }: CardType) => ( ( { @@ -13,11 +14,10 @@ export function useRefetchLocation(currentBookId, data, refetch) { setRelatedBooks(filteredBooks); - if (location.pathname !== previousPathname) { + if (pathname !== previousPathname) { refetch(); - setPreviousPathname(location.pathname); + setPreviousPathname(pathname); } - }, [data, currentBookId, location.pathname, refetch, previousPathname]); - + }, [data, currentBookId, pathname, refetch, previousPathname]); return relatedBooks; }