From ed8a1c2f574ebb850712b1ad39658892ee5383dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Tue, 6 Feb 2024 15:01:03 -0600 Subject: [PATCH] fix: no fallback on state change --- .../tankopedia/components/TankSearch/index.tsx | 12 +++++++----- src/app/tools/tankopedia/page.tsx | 14 +++++--------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/app/tools/tankopedia/components/TankSearch/index.tsx b/src/app/tools/tankopedia/components/TankSearch/index.tsx index 277a61520..bf73c9634 100644 --- a/src/app/tools/tankopedia/components/TankSearch/index.tsx +++ b/src/app/tools/tankopedia/components/TankSearch/index.tsx @@ -47,9 +47,10 @@ export function TankSearch({ compact, onSelect = () => {} }: TankSearchProps) { const nations = use(NATIONS); const filters = useTankopediaPersistent((state) => state.filters); const sort = useTankopediaPersistent((state) => state.sort); - const awaitedTanks = use( - tanksDefinitionsArray.then((tanks) => - tanks + const awaitedTanks = use(tanksDefinitionsArray); + const defaultSortedTanks = useMemo( + () => + awaitedTanks .sort( (a, b) => treeTypeOrder.indexOf(a.treeType) - @@ -60,12 +61,12 @@ export function TankSearch({ compact, onSelect = () => {} }: TankSearchProps) { tankTypeOrder.indexOf(a.type) - tankTypeOrder.indexOf(b.type), ) .sort((a, b) => nations.indexOf(a.nation) - nations.indexOf(b.nation)), - ), + [], ); const input = useRef(null); const searchableTanks = useMemo( () => - awaitedTanks + defaultSortedTanks .filter( (tank) => (filters.tiers.length === 0 @@ -134,6 +135,7 @@ export function TankSearch({ compact, onSelect = () => {} }: TankSearchProps) { + - Loading...}> - { - router.push(`./tankopedia/${tank.id}`); - }} - /> - + { + router.push(`./tankopedia/${tank.id}`); + }} + /> ); }