diff --git a/public/components/DataSourceAlertsCard/DataSourceAlertsCard.tsx b/public/components/DataSourceAlertsCard/DataSourceAlertsCard.tsx index 6dd41b89..2e91ea87 100644 --- a/public/components/DataSourceAlertsCard/DataSourceAlertsCard.tsx +++ b/public/components/DataSourceAlertsCard/DataSourceAlertsCard.tsx @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import React, { useCallback, useEffect, useState } from "react"; +import React, { useCallback, useEffect, useMemo, useState } from "react"; import { EuiBadge, EuiDescriptionList, EuiEmptyPrompt, EuiFlexGroup, EuiFlexItem, EuiHorizontalRule, EuiLink, EuiLoadingContent, EuiPanel, EuiText, EuiTitle } from "@elastic/eui"; import { DataSourceManagementPluginSetup, DataSourceOption } from "../../../../../src/plugins/data_source_management/public"; import { getApplication, getClient, getNotifications, getSavedObjectsClient } from "../../services"; @@ -18,7 +18,13 @@ export interface DataSourceAlertsCardProps { } export const DataSourceAlertsCard: React.FC = ({ getDataSourceMenu }) => { - const DataSourceSelector = getDataSourceMenu?.(); + const DataSourceSelector = useMemo(() => { + if (getDataSourceMenu) { + return getDataSourceMenu(); + } + + return null; + }, [getDataSourceMenu]); const [loading, setLoading] = useState(false); const [dataSource, setDataSource] = useState({ label: 'Local cluster',