Skip to content

Commit

Permalink
fix: data source picker remount multiple times (#1192)
Browse files Browse the repository at this point in the history
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
(cherry picked from commit 37ac7d2)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] committed Oct 23, 2024
1 parent 137e211 commit c5af4e6
Showing 1 changed file with 8 additions and 2 deletions.
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 {
EuiBasicTable,
EuiBasicTableColumn,
Expand Down Expand Up @@ -46,7 +46,13 @@ export const DataSourceThreatAlertsCard: React.FC<DataSourceAlertsCardProps> = (
getDataSourceMenu,
detectorService,
}) => {
const DataSourceSelector = getDataSourceMenu?.();
const DataSourceSelector = useMemo(() => {
if (getDataSourceMenu) {
return getDataSourceMenu();
}

return null;
}, [getDataSourceMenu]);
const notifications = getNotifications();
const [loading, setLoading] = useState(false);
const [dataSource, setDataSource] = useState<DataSourceOption>({
Expand Down

0 comments on commit c5af4e6

Please sign in to comment.