From a368e7f2771fc4a0d9b15542d2c464097fcb7e59 Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Tue, 20 Jul 2021 16:19:11 +0200 Subject: [PATCH] fix: prevent early redirection from email-signup (#42944) Co-authored-by: Victor Duarte Co-authored-by: Shaun Hamilton Co-authored-by: Victor Duarte Co-authored-by: Shaun Hamilton --- client/src/pages/email-sign-up.tsx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/client/src/pages/email-sign-up.tsx b/client/src/pages/email-sign-up.tsx index 03ee0c98e0..d6f17e015b 100644 --- a/client/src/pages/email-sign-up.tsx +++ b/client/src/pages/email-sign-up.tsx @@ -37,18 +37,22 @@ function AcceptPrivacyTerms({ acceptedPrivacyTerms, t }: AcceptPrivacyTermsProps) { - // if a user navigates away from here we should set acceptedPrivacyTerms - // to true (so they do not get pulled back) without changing their email - // preferences (hence the null payload) - // This ensures the user has to click the checkbox and then click the - // 'Continue...' button to sign up. useEffect(() => { return () => { + // if a user navigates away from here we should set acceptedPrivacyTerms + // to true (so they do not get pulled back) without changing their email + // preferences (hence the null payload) + // This makes sure that the user has to opt in to Quincy's emails and that + // they are only asked twice if (!acceptedPrivacyTerms) { acceptTerms(null); } }; - }, [acceptTerms, acceptedPrivacyTerms]); + // We're ignoring all dependencies, since this effect must only run once + // (when the user leaves the page). + // TODO: figure out how to useCallback to only run this effect once. + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); function onClick(isWeeklyEmailAccepted: boolean) { acceptTerms(isWeeklyEmailAccepted);