Skip to content

Commit

Permalink
fix:로그인유효성추가,코드수정 #4
Browse files Browse the repository at this point in the history
  • Loading branch information
JH-anfseo committed Jan 12, 2023
1 parent 7c244fa commit 7a8b0d6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/Hooks/useLogin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand All @@ -19,8 +18,9 @@ export const useSignIn = () => {
alert('비밀번호가 틀렸습니다.');
}
},
onSuccess: ({ navigate }) => {
//navigate('Tabs', { screen: '메인 페이지' });
onSuccess: () => {
//네비게이션 메인페이지 이동
navigate('Tabs', { screen: '메인 페이지' });
},
});
};
3 changes: 1 addition & 2 deletions src/screen/LoginPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -48,7 +48,6 @@ const LoginPage = ({ navigation: { navigate } }) => {
SignIn({ email, password, navigate });
setEmail('');
setpassword('');
navigate('Tabs', { screen: '메인 페이지' });
}
};

Expand Down

0 comments on commit 7a8b0d6

Please sign in to comment.