Skip to content

Commit

Permalink
fix: data source picker is remounted multiple times (#1131)
Browse files Browse the repository at this point in the history
Signed-off-by: SuZhou-Joe <[email protected]>
  • Loading branch information
SuZhou-Joe authored Oct 23, 2024
1 parent 37a6ce5 commit 7deec89
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions public/components/DataSourceAlertsCard/DataSourceAlertsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -18,7 +18,13 @@ export interface DataSourceAlertsCardProps {
}

export const DataSourceAlertsCard: React.FC<DataSourceAlertsCardProps> = ({ getDataSourceMenu }) => {
const DataSourceSelector = getDataSourceMenu?.();
const DataSourceSelector = useMemo(() => {
if (getDataSourceMenu) {
return getDataSourceMenu();
}

return null;
}, [getDataSourceMenu]);
const [loading, setLoading] = useState(false);
const [dataSource, setDataSource] = useState<DataSourceOption>({
label: 'Local cluster',
Expand Down

0 comments on commit 7deec89

Please sign in to comment.