Skip to content

Commit

Permalink
fix: data source picker is remounted multiple times (#1131) (#1137)
Browse files Browse the repository at this point in the history
(cherry picked from commit 7deec89)

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent a239f6f commit 4dfa34f
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 4dfa34f

Please sign in to comment.