diff --git a/src/Components/SmartComponents/CVEs/CVEs.js b/src/Components/SmartComponents/CVEs/CVEs.js index 567f9402f..d09b4975a 100644 --- a/src/Components/SmartComponents/CVEs/CVEs.js +++ b/src/Components/SmartComponents/CVEs/CVEs.js @@ -35,7 +35,10 @@ export const CVEs = ({ rbac }) => { const dispatch = useDispatch(); const [CveStatusModal, setStatusModal] = useState(() => () => null); const [CveBusinessRiskModal, setBusinessRiskModal] = useState(() => () => null); - const [isFirstLoad, setFirstLoad] = useState(true); + + // This state causes a re-render when updateRef is called in and + // to fetch the updated status of the CVEs + const [causeARerender, setCauseARerender] = useState(false); const [[ canEditStatusOrBusinessRisk, @@ -81,14 +84,9 @@ export const CVEs = ({ rbac }) => { }, [shouldUseHybridSystemFilter]); useEffect(() => { - if (isFirstLoad) { - setFirstLoad(false); - } - else { - dispatch(fetchCveListByAccount(parameters, shouldUseHybridSystemFilter)); - setUrlParam({ ...parameters }); - } - }, [parameters, isFirstLoad, shouldUseHybridSystemFilter]); + dispatch(fetchCveListByAccount(parameters, shouldUseHybridSystemFilter)); + setUrlParam({ ...parameters }); + }, [parameters, causeARerender, shouldUseHybridSystemFilter]); useEffect(() => { return () => { @@ -119,7 +117,7 @@ export const CVEs = ({ rbac }) => { { - setFirstLoad(true); + setCauseARerender(!causeARerender); dispatch(clearCVEsStore()); updateRef(goToFirstPage ? { ...meta, page: 1 } : meta, parameters, apply); }} @@ -134,7 +132,7 @@ export const CVEs = ({ rbac }) => { cves={cvesList} canEditPairStatus={canEditPairStatus} updateRef={() => { - setFirstLoad(true); + setCauseARerender(!causeARerender); dispatch(clearCVEsStore()); updateRef(goToFirstPage ? { ...meta, page: 1 } : meta, parameters, apply); }}