Skip to content

Commit

Permalink
fix(SPM-2117): remove await inside react hook (#1089)
Browse files Browse the repository at this point in the history
* fix(SPM-2117): remove await inside react hook

* chore: bring back the useEffect dependencies

* chore: remove unneseccary npm script
  • Loading branch information
mkholjuraev authored Jul 13, 2023
1 parent 83f93b4 commit cddb13e
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useMemo } from 'react';
import React from 'react';
import { useSelector } from 'react-redux';
import { CheckCircleIcon, PackageIcon, ExclamationTriangleIcon } from '@patternfly/react-icons';
import propTypes from 'prop-types';
Expand Down Expand Up @@ -46,27 +46,33 @@ const SystemsStatusReport = ({ apply, queryParams }) => {

const { selectedTags, selectedGlobalTags, systemProfile } = useSelector(({ GlobalFilterStore }) => GlobalFilterStore);

const res = useMemo(async () =>{
const fetchResource = () => {
setSubtotals({});

let result;

try {
result = await fetchSystems({
result = fetchSystems({
filter: {
os: queryParams?.filter?.os
},
selectedTags: [...selectedTags, ...selectedGlobalTags],
systemProfile,
limit: 1,
'filter[stale]': 'in:true,false'
}).then((result)=> {
setSubtotals(result.meta?.subtotals);
});
}
catch {
result = [];
}

return result;
};

React.useEffect(() => {
fetchResource();
}, [
queryParams?.filter?.os?.length, queryParams?.filter?.os !== undefined,
selectedTags?.length, selectedTags !== undefined,
Expand All @@ -75,10 +81,6 @@ const SystemsStatusReport = ({ apply, queryParams }) => {
queryParams?.subtotals !== undefined
]);

res.then((result)=> {
setSubtotals(result.meta?.subtotals);
});

return (
<Main style={{ paddingBottom: 0 }}>
<Grid hasGutter span={12} >
Expand Down

0 comments on commit cddb13e

Please sign in to comment.