Skip to content

Commit ad174ce

Browse files
committed
chore: updated react-virtual package
1 parent 228c021 commit ad174ce

File tree

4 files changed

+23
-15
lines changed

4 files changed

+23
-15
lines changed

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"@tailwindcss/vite": "^4.1.18",
3232
"@tanstack/react-query": "^5.90.12",
3333
"@tanstack/react-query-devtools": "^5.91.1",
34-
"@tanstack/react-virtual": "^3.13.12",
34+
"@tanstack/react-virtual": "^3.13.13",
3535
"@tensorflow/tfjs": "^4.22.0",
3636
"@types/recharts": "^2.0.1",
3737
"class-variance-authority": "^0.7.1",

frontend/src/components/CardsTable.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useVirtualizer } from '@tanstack/react-virtual'
22
import i18n from 'i18next'
3-
import { type ReactNode, useEffect, useMemo, useRef, useState } from 'react'
3+
import { type ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react'
44
import { useTranslation } from 'react-i18next'
55
import { getExpansionById } from '@/lib/CardsDB.ts'
66
import { chunk, cn } from '@/lib/utils.ts'
@@ -75,10 +75,14 @@ export function CardsTable({ className, children, cards, groupExpansions, render
7575
[cards, cardsPerRow],
7676
)
7777

78+
const getItemKey = useCallback((index: number) => {
79+
return rows[index].id // critical: stable keys per logical row
80+
}, [])
81+
7882
const rowVirtualizer = useVirtualizer({
7983
getScrollElement: () => scrollRef.current,
8084
count: rows.length,
81-
getItemKey: (index) => rows[index].id, // critical: stable keys per logical row
85+
getItemKey,
8286
estimateSize: (index) => (rows[index].type === 'header' ? 52 : cardHeight + 8),
8387
overscan: 5,
8488
})
@@ -102,7 +106,7 @@ export function CardsTable({ className, children, cards, groupExpansions, render
102106
<img
103107
src={`/images/sets/${i18n.language}/${row.expansion.id}.webp`}
104108
alt={row.expansion.name}
105-
className="max-w-[60px]"
109+
className="max-w-15"
106110
onError={(e) => {
107111
;(e.target as HTMLImageElement).src = `/images/sets/en-US/${row.expansion.id}.webp`
108112
}}

frontend/src/pages/trade/TradeMatches.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useVirtualizer } from '@tanstack/react-virtual'
22
import { ChevronRight } from 'lucide-react'
3-
import { useMemo, useRef, useState } from 'react'
3+
import { useCallback, useMemo, useRef, useState } from 'react'
44
import { useTranslation } from 'react-i18next'
55
import { Link } from 'react-router'
66
import { CardLine } from '@/components/CardLine'
@@ -22,10 +22,14 @@ function TradeMatches() {
2222

2323
const { data: tradingPartners, isLoading, isError } = useTradingPartners(showResults, selectedCard)
2424

25+
const getItemKey = useCallback((index: number) => {
26+
return cards[index].card_id
27+
}, [])
28+
2529
const virtualizer = useVirtualizer({
2630
getScrollElement: () => scrollRef.current,
2731
count: cards.length,
28-
getItemKey: (index) => cards[index].card_id,
32+
getItemKey,
2933
estimateSize: () => 32,
3034
})
3135

pnpm-lock.yaml

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)