Skip to content

Commit 124d317

Browse files
committed
1 parent b6ff645 commit 124d317

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/hoc/withAuthentication.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,20 @@ export default function withAuthentication(Component) {
1313
let [authError, setAuthError] = useState(false);
1414

1515
useEffect(() => {
16+
// prevent page redirecting to login page when unmount
17+
let isUnmount = false;
1618
getAuthUserTokens()
1719
.then(({ tokenV3 }) => {
1820
if (!!tokenV3) {
1921
setIsLoggedIn(!!tokenV3);
20-
} else {
22+
} else if (!isUnmount) {
2123
login();
2224
}
2325
})
2426
.catch(setAuthError);
27+
return () => {
28+
isUnmount = true;
29+
};
2530
}, []);
2631

2732
return (

0 commit comments

Comments
 (0)