Skip to content

Commit

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

Signed-off-by: SuZhou-Joe <[email protected]>
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 801d1d3 commit 7c3ff55
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 7c3ff55

Please sign in to comment.