diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_add.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_add.tsx index 8af8ddb3fcfe1..34a4c909c65a9 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_add.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_add.tsx @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import React, { useCallback, useReducer, useState, useEffect } from 'react'; +import React, { useCallback, useReducer, useMemo, useState, useEffect } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiTitle, EuiFlyoutHeader, EuiFlyout, EuiFlyoutBody, EuiPortal } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; @@ -35,17 +35,20 @@ export const AlertAdd = ({ alertTypeId, initialValues, }: AlertAddProps) => { - const initialAlert: InitialAlert = { - params: {}, - consumer, - alertTypeId, - schedule: { - interval: '1m', - }, - actions: [], - tags: [], - ...(initialValues ? initialValues : {}), - }; + const initialAlert: InitialAlert = useMemo( + () => ({ + params: {}, + consumer, + alertTypeId, + schedule: { + interval: '1m', + }, + actions: [], + tags: [], + ...(initialValues ? initialValues : {}), + }), + [alertTypeId, consumer, initialValues] + ); const [{ alert }, dispatch] = useReducer(alertReducer as InitialAlertReducer, { alert: initialAlert,