You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by vi...@apache.org on 2021/01/29 14:25:39 UTC

[superset] 01/18: fix(alerts/reports): misconfigured useEffect hook breaks form validation in prod builds (#12779)

This is an automated email from the ASF dual-hosted git repository.

villebro pushed a commit to branch 1.0
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 60545c9b233316ea1823e35b8fbe22f2418dd447
Author: ʈᵃᵢ <td...@gmail.com>
AuthorDate: Tue Jan 26 13:44:15 2021 -0800

    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 fba09c6..5c5f229 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<AlertReportModalProps> = ({
   }, [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) {