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 3c7f9a8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/Navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function Navbar(props: Props) {
<div className={styles.brand}>
<Link
className={styles.alertHubTitle}
to="home"
to="/"
>
<img
className={styles.goIcon}
Expand Down
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 3c7f9a8

Please sign in to comment.