Replace loadHost with an IIFE

This commit is contained in:
Marliana Lara
2020-01-22 12:25:43 -05:00
parent d33bbdd4f6
commit fc5363a140

View File

@@ -39,9 +39,11 @@ function Host({ inventory, i18n, setBreadcrumb }) {
? '/hosts' ? '/hosts'
: `/inventories/inventory/${inventoriesMatch.params.id}/hosts`; : `/inventories/inventory/${inventoriesMatch.params.id}/hosts`;
const loadHost = async () => { useEffect(() => {
(async () => {
setContentError(null); setContentError(null);
setHasContentLoading(true); setHasContentLoading(true);
try { try {
const hostId = hostsMatch const hostId = hostsMatch
? hostsMatch.params.id ? hostsMatch.params.id
@@ -59,10 +61,7 @@ function Host({ inventory, i18n, setBreadcrumb }) {
} finally { } finally {
setHasContentLoading(false); setHasContentLoading(false);
} }
}; })();
useEffect(() => {
loadHost();
}, [location]); // eslint-disable-line react-hooks/exhaustive-deps }, [location]); // eslint-disable-line react-hooks/exhaustive-deps
const tabsArray = [ const tabsArray = [