From b6fc2d5b56a0fec6eca653685a6e2922a7b58ad3 Mon Sep 17 00:00:00 2001 From: Jialei Date: Mon, 4 Dec 2023 11:16:11 +0800 Subject: [PATCH] fix(console): prevent dead loop when list datastore tables (#3053) --- .../src/datastore/hooks/useFetchDatastoreAllTables.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/console/packages/starwhale-core/src/datastore/hooks/useFetchDatastoreAllTables.tsx b/console/packages/starwhale-core/src/datastore/hooks/useFetchDatastoreAllTables.tsx index 6a10a5d3b9..6643d6eaad 100644 --- a/console/packages/starwhale-core/src/datastore/hooks/useFetchDatastoreAllTables.tsx +++ b/console/packages/starwhale-core/src/datastore/hooks/useFetchDatastoreAllTables.tsx @@ -22,8 +22,9 @@ export function useFetchDatastoreAllTables( const allTables = useListDatastoreTables(params, !!params) const tables = React.useMemo(() => { - return allTables.data?.tables?.sort((a, b) => (a > b ? 1 : -1)) ?? [] - }, [allTables]) + const _tables = allTables.data?.tables ?? [] + return [..._tables].sort((a, b) => (a > b ? 1 : -1)) + }, [allTables.data]) return { isSuccess: allTables.isSuccess,