diff --git a/src/Hooks/useLogin.js b/src/Hooks/useLogin.js index 8298dd3..793939c 100644 --- a/src/Hooks/useLogin.js +++ b/src/Hooks/useLogin.js @@ -7,9 +7,8 @@ export const SignIn = async (payload) => { const { email, password } = payload; Keyboard.dismiss(); // 버튼 클릭 시 키보드 접기 return signInWithEmailAndPassword(auth, email, password); - //navigate('Tabs', { screen: '메인 페이지' }) }; -export const useSignIn = () => { +export const useSignIn = (navigate) => { return useMutation(SignIn, { onError: (err) => { if (err.message.includes('user-not-found')) { @@ -19,8 +18,9 @@ export const useSignIn = () => { alert('비밀번호가 틀렸습니다.'); } }, - onSuccess: ({ navigate }) => { - //navigate('Tabs', { screen: '메인 페이지' }); + onSuccess: () => { + //네비게이션 메인페이지 이동 + navigate('Tabs', { screen: '메인 페이지' }); }, }); }; diff --git a/src/screen/LoginPage.jsx b/src/screen/LoginPage.jsx index 0ca90ee..9bb2656 100644 --- a/src/screen/LoginPage.jsx +++ b/src/screen/LoginPage.jsx @@ -25,7 +25,7 @@ const LoginPage = ({ navigation: { navigate } }) => { const matchedEmail = email.match(regex.email); const matchedPw = password.match(regex.password); - const { onSuccess, mutate: SignIn } = useSignIn(); + const { mutate: SignIn } = useSignIn(navigate); //이메일이나 비밀번호가 빈칸이면 alert출력 const handleLogin = (email, password) => { @@ -48,7 +48,6 @@ const LoginPage = ({ navigation: { navigate } }) => { SignIn({ email, password, navigate }); setEmail(''); setpassword(''); - navigate('Tabs', { screen: '메인 페이지' }); } };