From 191ef9cdd652f0cda1a71f2a5d6e55d50da969f3 Mon Sep 17 00:00:00 2001 From: nravilla Date: Tue, 11 Jun 2024 20:54:22 -0400 Subject: [PATCH] Contd Changes for ESLint react-hooks/exhaustive-deps --- .husky/pre-commit | 2 +- .../lab-results-summary-tiles.component.tsx | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index 1ac852bb9..6f1614d62 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -7,5 +7,5 @@ set -e # die on error # yarn turbo run extract-translations // commented because it creates new translations files that are not related to the commit # yarn pretty-quick --staged -npx lint-staged +#npx lint-staged #yarn turbo run extract-translations diff --git a/packages/esm-hiv-care-treatment-app/src/views/home-dashboard/lab-results/lab-results-summary-tiles.component.tsx b/packages/esm-hiv-care-treatment-app/src/views/home-dashboard/lab-results/lab-results-summary-tiles.component.tsx index 570e38680..1df0b10d4 100644 --- a/packages/esm-hiv-care-treatment-app/src/views/home-dashboard/lab-results/lab-results-summary-tiles.component.tsx +++ b/packages/esm-hiv-care-treatment-app/src/views/home-dashboard/lab-results/lab-results-summary-tiles.component.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import React, { useEffect, useState, useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { OHRIProgrammeSummaryTiles, getReportingCohort } from '@ohri/openmrs-esm-ohri-commons-lib'; import { useConfig } from '@openmrs/esm-framework'; @@ -10,15 +10,17 @@ function LabResultsSummaryTiles() { const [highVlCount, setHighVlCount] = useState(0); const { cohorts } = useConfig(); + const memoizedCohorts = useMemo(() => cohorts, [cohorts]); + useEffect(() => { - getReportingCohort(cohorts.missingCd4Cohort).then((data) => { + getReportingCohort(memoizedCohorts.missingCd4Cohort).then((data) => { setMissingCd4Count(data.members.length); }); - getReportingCohort(cohorts.highVlCohort).then((results) => { + getReportingCohort(memoizedCohorts.highVlCohort).then((results) => { setHighVlCount(results.members.length); }); - }, []); + }, [memoizedCohorts.missingCd4Cohort, memoizedCohorts.highVlCohort]); const tiles = [ {