From 0af9e016100d9c8d7ebae7cd3a741ea7b9ca1130 Mon Sep 17 00:00:00 2001 From: Jake McDermott Date: Mon, 24 Aug 2020 12:55:32 -0400 Subject: [PATCH] Don't display facts until facts are loaded --- .../InventoryHostFacts/InventoryHostFacts.jsx | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/awx/ui_next/src/screens/Inventory/InventoryHostFacts/InventoryHostFacts.jsx b/awx/ui_next/src/screens/Inventory/InventoryHostFacts/InventoryHostFacts.jsx index e0940a4531..2f24b4cb38 100644 --- a/awx/ui_next/src/screens/Inventory/InventoryHostFacts/InventoryHostFacts.jsx +++ b/awx/ui_next/src/screens/Inventory/InventoryHostFacts/InventoryHostFacts.jsx @@ -11,32 +11,31 @@ import useRequest from '../../../util/useRequest'; import { HostsAPI } from '../../../api'; function InventoryHostFacts({ i18n, host }) { - const { result: facts, isLoading, error, request: fetchFacts } = useRequest( + const { request, isLoading, error, result } = useRequest( useCallback(async () => { - const [{ data: factsObj }] = await Promise.all([ - HostsAPI.readFacts(host.id), - ]); - return JSON.stringify(factsObj, null, 4); + const { data } = await HostsAPI.readFacts(host.id); + + return JSON.stringify(data, null, 4); }, [host]), - '{}' + null ); useEffect(() => { - fetchFacts(); - }, [fetchFacts]); - - if (isLoading) { - return ; - } + request(); + }, [request]); if (error) { return ; } + if (isLoading || result === null) { + return ; + } + return ( - + );