✋🏻gif가 로딩중이에요!

preplay1-min.gif

  1. firebase 인증키로 auth export
const firebaseConfig = {
  apiKey: '',
  authDomain: '',
  projectId: '',
  storageBucket: '',
  messagingSenderId: '',
  appId: '',
  measurementId: '',
};

export const auth = getAuth(app);
  1. signInWithPopup에 구글provider를 파라미터로 전달
import { app } from '@src/firebaseConfig';
import { useQuery } from '@tanstack/react-query';
import { getAuth, GoogleAuthProvider, signInWithPopup } from 'firebase/auth';

const loginWithGoogle = async () => {
  const provider = new GoogleAuthProvider();
  return (await signInWithPopup(getAuth(app), provider)).user;
};
export default () =>
  useQuery(['userInfo'], loginWithGoogle, {
    staleTime: Infinity,
    cacheTime: Infinity,
    enabled: false,
  });
  1. 로그인 감지 hook
import { useCookies } from 'react-cookie';

export default () => {
  const [cookies, setCookie] = useCookies(['uid']);
  const me = cookies.uid;

  return me;
};

//mypage 컴포넌트
const me = useIsLogin(); //로그인 유무 확인