Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 애니 목록 페이지 탭전환시 애니 카드 복사되는 현상 수정 #358

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/features/animes/routes/List/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ export default function AnimeList() {
applyFilters,
} = useFilterAnimes();

/** 중복된 데이터 제거 */
const uniqueAnimesQuery = {
...animesQuery.data,
pages: [
...new Set(animesQuery.data?.pages.map((page) => JSON.stringify(page))),
].map((page) => JSON.parse(page)),
};

const observeRef = useRef<HTMLDivElement>(null);
const navigate = useNavigate();

Expand Down Expand Up @@ -92,13 +100,13 @@ export default function AnimeList() {
<GridAnimeCardSkeleton key={i} />
))}

{animesQuery.data?.pages.length === 0 && (
{uniqueAnimesQuery.pages.length === 0 && (
<Empty message="애니가 없어요" />
)}

{animesQuery.data && (
<>
{animesQuery.data?.pages.map((item) => (
{uniqueAnimesQuery.pages.map((item) => (
<AnimeCard
{...item}
key={item.id}
Expand Down
Loading