From 02e985c011d429ea82874a8f6ffc841670288389 Mon Sep 17 00:00:00 2001 From: Drsakura Date: Thu, 10 Sep 2026 17:52:56 +0800 Subject: [PATCH] =?UTF-8?q?fix(suppliers):=20=E4=B8=BB=E8=90=A5=E7=B1=BB?= =?UTF-8?q?=E7=9B=AE=E5=8E=BB=E9=87=8D=EF=BC=8C=E6=B6=88=E9=99=A4=20React?= =?UTF-8?q?=20=E9=87=8D=E5=A4=8D=20key=20=E8=AD=A6=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit splitCats 未去重,源数据里同一类目重复登记时(如「游标卡尺;游标卡尺」) 会渲染出两个 key 相同的 chip。React 会因此报 'Encountered two children with the same key',且该行为官方标注为 unsupported。 在 splitCats 出口处按原顺序去重,既消警告也避免卡片上出现重复标签。 由无头浏览器全站巡检发现(供应商页原本有 22 条此类警告)。 --- frontend/src/pages/SupplierManagement.jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/src/pages/SupplierManagement.jsx b/frontend/src/pages/SupplierManagement.jsx index 9fc65b3..778f571 100644 --- a/frontend/src/pages/SupplierManagement.jsx +++ b/frontend/src/pages/SupplierManagement.jsx @@ -26,10 +26,13 @@ function fmtDate(iso, withTime = true) { } function splitCats(text) { - return String(text || '') + const list = String(text || '') .split(/[、,,;;/|\s]+/) .map((t) => t.trim()) .filter(Boolean) + /* 源数据里同一类目可能重复登记(如「游标卡尺;游标卡尺」), + 去重后再渲染,顺带避免 React 因 key 重复而发出警告。 */ + return [...new Set(list)] } /** 从完整地址里抽出省市,卡片上只显示大致方位 */