From e7878906718c48f7437393d43f38591b92d097c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A2=AB=E9=9B=A8=E6=B0=B4=E8=BF=87=E6=BB=A4=E7=9A=84?= =?UTF-8?q?=E7=A9=BA=E6=B0=94-Rairn?= <958414905@qq.com> Date: Thu, 25 May 2023 12:24:47 +0800 Subject: [PATCH] fix(ConfigurationTabs): avoid error (#1782) --- .../Configuration/ConfigurationTabs.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/core/client/src/collection-manager/Configuration/ConfigurationTabs.tsx b/packages/core/client/src/collection-manager/Configuration/ConfigurationTabs.tsx index b7dbdbeda9..945e0a212d 100644 --- a/packages/core/client/src/collection-manager/Configuration/ConfigurationTabs.tsx +++ b/packages/core/client/src/collection-manager/Configuration/ConfigurationTabs.tsx @@ -114,6 +114,12 @@ export const ConfigurationTabs = () => { const { data, refresh } = useContext(CollectionCategroriesContext); const { refresh: refreshCM, run, defaultRequest, setState } = useResourceActionContext(); const [key, setKey] = useState('all'); + const [activeKey, setActiveKey] = useState('all'); + const compile = useCompile(); + const api = useAPIClient(); + + if (!data) return null; + const tabsItems = data .sort((a, b) => b.sort - a.sort) .concat() @@ -131,9 +137,7 @@ export const ConfigurationTabs = () => { closable: false, schema: collectionTableSchema, }); - const compile = useCompile(); - const [activeKey, setActiveKey] = useState('all'); - const api = useAPIClient(); + const onChange = (key: string) => { setActiveKey(key); setKey(uid());