diff --git a/x-pack/plugins/security_solution/public/detections/components/rules/rule_preview/index.tsx b/x-pack/plugins/security_solution/public/detections/components/rules/rule_preview/index.tsx index 55931e74ff9d4..c4d50062675d2 100644 --- a/x-pack/plugins/security_solution/public/detections/components/rules/rule_preview/index.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/rules/rule_preview/index.tsx @@ -25,7 +25,7 @@ import { isEqual } from 'lodash'; import * as i18n from './translations'; import { usePreviewRoute } from './use_preview_route'; import { PreviewHistogram } from './preview_histogram'; -import { PreviewLogsComponent } from './preview_logs'; +import { PreviewLogs } from './preview_logs'; import { useKibana } from '../../../../common/lib/kibana'; import { LoadingHistogram } from './loading_histogram'; import { useStartTransaction } from '../../../../common/lib/apm/use_start_transaction'; @@ -274,7 +274,7 @@ const RulePreviewComponent: React.FC = ({ timeframeOptions={previewData.timeframeOptions} /> )} - + ); }; diff --git a/x-pack/plugins/security_solution/public/detections/components/rules/rule_preview/preview_histogram.tsx b/x-pack/plugins/security_solution/public/detections/components/rules/rule_preview/preview_histogram.tsx index 89ed3aaf97b91..24f6b82383a13 100644 --- a/x-pack/plugins/security_solution/public/detections/components/rules/rule_preview/preview_histogram.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/rules/rule_preview/preview_histogram.tsx @@ -69,7 +69,7 @@ interface PreviewHistogramProps { const DEFAULT_HISTOGRAM_HEIGHT = 300; -export const PreviewHistogram = ({ +const PreviewHistogramComponent = ({ previewId, addNoiseWarning, spaceId, @@ -262,3 +262,6 @@ export const PreviewHistogram = ({ ); }; + +export const PreviewHistogram = React.memo(PreviewHistogramComponent); +PreviewHistogram.displayName = 'PreviewHistogram'; diff --git a/x-pack/plugins/security_solution/public/detections/components/rules/rule_preview/preview_logs.tsx b/x-pack/plugins/security_solution/public/detections/components/rules/rule_preview/preview_logs.tsx index b6f9135c8b99f..1c01a0491e92c 100644 --- a/x-pack/plugins/security_solution/public/detections/components/rules/rule_preview/preview_logs.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/rules/rule_preview/preview_logs.tsx @@ -10,7 +10,7 @@ import { EuiCallOut, EuiText, EuiSpacer, EuiAccordion } from '@elastic/eui'; import type { RulePreviewLogs } from '../../../../../common/api/detection_engine'; import * as i18n from './translations'; -interface PreviewLogsComponentProps { +interface PreviewLogsProps { logs: RulePreviewLogs[]; hasNoiseWarning: boolean; isAborted: boolean; @@ -42,11 +42,7 @@ const addLogs = ( allLogs: SortedLogs[] ) => (logs.length ? [{ startedAt, logs, duration }, ...allLogs] : allLogs); -export const PreviewLogsComponent: React.FC = ({ - logs, - hasNoiseWarning, - isAborted, -}) => { +const PreviewLogsComponent: React.FC = ({ logs, hasNoiseWarning, isAborted }) => { const sortedLogs = useMemo( () => logs.reduce<{ @@ -73,6 +69,9 @@ export const PreviewLogsComponent: React.FC = ({ ); }; +export const PreviewLogs = React.memo(PreviewLogsComponent); +PreviewLogs.displayName = 'PreviewLogs'; + const LogAccordion: React.FC = ({ logs, isError, children }) => { const firstLog = logs[0]; if (!(children || firstLog)) return null;