From 2e5668431428a9acc32e8a3f3528ae9e1ea440f0 Mon Sep 17 00:00:00 2001 From: Harpreet Singh Date: Thu, 5 Jan 2023 10:54:34 +1300 Subject: [PATCH] Move enable save button logic to a use effect hook. This updates state without delay. (#2548) --- web/components/config/notification/twitter.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/web/components/config/notification/twitter.tsx b/web/components/config/notification/twitter.tsx index c31d99c43..4dd850305 100644 --- a/web/components/config/notification/twitter.tsx +++ b/web/components/config/notification/twitter.tsx @@ -66,14 +66,16 @@ export const ConfigNotify = () => { ); }; + useEffect(() => { + setEnableSaveButton(canSave()); + }, [formDataValues]); + // update individual values in state const handleFieldChange = ({ fieldName, value }: UpdateArgs) => { setFormDataValues({ ...formDataValues, [fieldName]: value, }); - - setEnableSaveButton(canSave()); }; // toggle switch.