Skip to content

Commit

Permalink
Add use memo in country filter
Browse files Browse the repository at this point in the history
  • Loading branch information
barshathakuri committed Apr 15, 2024
1 parent 8fcfe6d commit f8ff993
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/views/Home/AlertsView/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useMemo } from 'react';
import { Link } from 'react-router-dom';
import {
gql,
Expand All @@ -18,6 +19,7 @@ import AlertsMap from './AlertsMap';
import i18n from './i18n.json';
import styles from './styles.module.css';

// NOTE: alertFilters is related with filteredAlertCount
const COUNTRIES_LIST = gql`
query CountryList {
public {
Expand Down Expand Up @@ -54,9 +56,9 @@ function AlertsView(props: Props) {
COUNTRIES_LIST,
);

const countriesWithAlert = countryResponse?.public.allCountries.filter(
const countriesWithAlert = useMemo(() => countryResponse?.public.allCountries.filter(
(country) => (country?.filteredAlertCount ?? 0) > 0,
);
), [countryResponse?.public.allCountries]);

return (
<Container
Expand Down

0 comments on commit f8ff993

Please sign in to comment.