Skip to content

Commit

Permalink
refactor: useQuery 추가 #1 #4
Browse files Browse the repository at this point in the history
useUID 커스텀 훅 생성
  • Loading branch information
no-pla committed Jan 9, 2023
1 parent 0ca32a9 commit 792abed
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions src/Hooks/useAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,26 @@ s;
export const handleSignUp = async (email, password) => {
Keyboard.dismiss(); // 버튼 클릭 시 키보드 접기
return createUserWithEmailAndPassword(auth, email, password);
// .then()
// .catch((error) => {
// if (error.message.includes('email-already-in-use')) {
// alert(
// '이미 가입된 이메일입니다. 로그인을 시도하거나 다른 이메일을 사용해 주세요.',
// );
// }
// console.log(error);
// });
};
useMutation(() => handleSignUp(email, password));

useMutation(() => handleSignUp(email, password), {
onError: (error) => {
if (error.message.includes('email-already-in-use')) {
alert(
'이미 가입된 이메일입니다. 로그인을 시도하거나 다른 이메일을 사용해 주세요.',
);
}
},
});

const getUID = () => {
return auth;
};

export const useUID = () => {
return useQuery('uid', getUID, {
select: (data) => {
return data?.currentUser?.uid;
},
});
};

0 comments on commit 792abed

Please sign in to comment.