From 3ed915146db70bd17b115fff50498fef97a25057 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CA=88=E1=B5=83=E1=B5=A2?= Date: Tue, 26 Jan 2021 13:44:15 -0800 Subject: [PATCH] fix(alerts/reports): misconfigured useEffect hook breaks form validation in prod builds (#12779) --- .../src/views/CRUD/alert/AlertReportModal.tsx | 38 +++++++++---------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/superset-frontend/src/views/CRUD/alert/AlertReportModal.tsx b/superset-frontend/src/views/CRUD/alert/AlertReportModal.tsx index fba09c6bf..5c5f2293d 100644 --- a/superset-frontend/src/views/CRUD/alert/AlertReportModal.tsx +++ b/superset-frontend/src/views/CRUD/alert/AlertReportModal.tsx @@ -992,27 +992,23 @@ const AlertReportModal: FunctionComponent = ({ }, [resource]); // Validation - useEffect( - () => { - validate(); - }, - currentAlert - ? [ - currentAlert.name, - currentAlert.owners, - currentAlert.database, - currentAlert.sql, - currentAlert.validator_config_json, - currentAlert.crontab, - currentAlert.working_timeout, - currentAlert.dashboard, - currentAlert.chart, - contentType, - notificationSettings, - conditionNotNull, - ] - : [], - ); + const currentAlertSafe = currentAlert || {}; + useEffect(() => { + validate(); + }, [ + currentAlertSafe.name, + currentAlertSafe.owners, + currentAlertSafe.database, + currentAlertSafe.sql, + currentAlertSafe.validator_config_json, + currentAlertSafe.crontab, + currentAlertSafe.working_timeout, + currentAlertSafe.dashboard, + currentAlertSafe.chart, + contentType, + notificationSettings, + conditionNotNull, + ]); // Show/hide if (isHidden && show) {