Skip to content

Commit

Permalink
fix: data source picker remount multiple times (#1192) (#1193)
Browse files Browse the repository at this point in the history
(cherry picked from commit 37ac7d2)

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 137e211 commit 1deba81
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 1deba81

Please sign in to comment.