0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-27 21:39:16 -05:00

fix(experience): move the navigate method to useEffect (#5027)

* fix(experience): move the navigate method to useEffect

move the navigate method to useEffect

* fix(experience): replace current nav history

replace current nav history
This commit is contained in:
simeng-li 2023-12-01 10:27:30 +08:00 committed by GitHub
parent d234c1483c
commit f74693d861
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,4 +1,4 @@
import { useContext } from 'react';
import { useContext, useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
import SecondaryPageLayout from '@/Layout/SecondaryPageLayout';
@ -20,10 +20,14 @@ const SingleSignOnConnectors = () => {
// Listen to native message
useNativeMessageListener();
// Return to the previous page if no email and no connectors are available in the context
if (!email || ssoConnectors.length === 0) {
navigate('../email');
}
useEffect(() => {
// Return to the previous page if no email and no connectors are available in the context
if (!email || ssoConnectors.length === 0) {
navigate('../email', {
replace: true,
});
}
}, [email, navigate, ssoConnectors.length]);
return (
<SecondaryPageLayout