From f803d60be1717d02f3977e3ae5d2a78dc5dc8aa9 Mon Sep 17 00:00:00 2001
From: Prathamesh Gawas <41731424+Prathamesh010@users.noreply.github.com>
Date: Wed, 8 Jun 2022 20:18:17 +0530
Subject: [PATCH] fix: multiple redirects after account deletion (#46350)
---
client/src/client-only-routes/show-settings.tsx | 5 +++--
client/src/redux/settings/danger-zone-saga.js | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/client/src/client-only-routes/show-settings.tsx b/client/src/client-only-routes/show-settings.tsx
index e8cf2e1cf7d..bdfd8925644 100644
--- a/client/src/client-only-routes/show-settings.tsx
+++ b/client/src/client-only-routes/show-settings.tsx
@@ -1,5 +1,5 @@
import { Grid } from '@freecodecamp/react-bootstrap';
-import React from 'react';
+import React, { useRef } from 'react';
import Helmet from 'react-helmet';
import { useTranslation } from 'react-i18next';
import { connect } from 'react-redux';
@@ -143,12 +143,13 @@ export function ShowSettings(props: ShowSettingsProps): JSX.Element {
verifyCert,
userToken
} = props;
+ const isSignedInRef = useRef(isSignedIn);
if (showLoading) {
return ;
}
- if (!isSignedIn) {
+ if (!isSignedInRef.current) {
navigate(`${apiLocation}/signin`);
return ;
}
diff --git a/client/src/redux/settings/danger-zone-saga.js b/client/src/redux/settings/danger-zone-saga.js
index 10d41d4d39d..d9d4e6741ff 100644
--- a/client/src/redux/settings/danger-zone-saga.js
+++ b/client/src/redux/settings/danger-zone-saga.js
@@ -19,7 +19,7 @@ function* deleteAccountSaga() {
);
// remove current user information from application state
yield put(resetUserData());
- yield call(navigate, '/');
+ yield call(navigate, '/learn');
} catch (e) {
yield put(deleteAccountError(e));
}