From 0ed6613382cb93db8ba44d2df1a807ceb1f2cd66 Mon Sep 17 00:00:00 2001 From: vivomo <929992114@qq.com> Date: Mon, 22 Jan 2024 01:36:57 +0800 Subject: [PATCH] fix: performance optimization --- packages/client/src/pages/game/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/client/src/pages/game/index.tsx b/packages/client/src/pages/game/index.tsx index 4d7152c..b7274eb 100644 --- a/packages/client/src/pages/game/index.tsx +++ b/packages/client/src/pages/game/index.tsx @@ -124,19 +124,19 @@ const Game = () => { }).sort((a, b) => b.oreBalance - a.oreBalance); }); - // const lootCache = useRef({}); + const lootCache = useRef({}); const PlayersData = useStore((state: any) => { const records = Object.values(state.getRecords(tables.Player)); return records.map((e:any) => { let playerItem = Object.assign(e.value, {addr: e.key.addr}) //LootList1Data let loot = LootList1Data.find((loot: any) => loot.addr == e.key.addr) || {}; - if (!playerItem.equip) { + if (!lootCache.current[loot.addr]) { // playerItem.equip = lootCache.current[loot.addr] let clothes = loot?.chest?.replace(/"(.*?)"/, '').split(' of')[0].replace(/^\s+|\s+$/g,"") let handheld = loot?.weapon?.replace(/"(.*?)"/, '').split(' of')[0].replace(/^\s+|\s+$/g,"") let head = loot?.head?.replace(/"(.*?)"/, '').split(' of')[0].replace(/^\s+|\s+$/g,"") - playerItem.equip = { + lootCache.current[loot.addr] = playerItem.equip = { clothes, handheld, head,