Skip to content

Commit

Permalink
Feature/#242 로그인 버그 픽스 (#251)
Browse files Browse the repository at this point in the history
* refactor : postGoogleLoginFetch -> postGoogleLogin

#242

* fix: useEffect 적용

- #242

* fix: fetch ok 수정 및 mount 전 로그인 버튼 안뜨게

- #242
  • Loading branch information
jasper200207 authored Jun 29, 2024
1 parent 4cce060 commit 692c92d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/app/api/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const fetcher = (options?: FetcherOptions) => {
if (interceptors?.response) {
response = await interceptors.response(response);
}
return await response.json();
return { ok: true, body: await response.json() };
} catch (error) {
let message = '';
if (error instanceof Error) message = error.message;
Expand Down
8 changes: 7 additions & 1 deletion src/containers/main/GoogleLoginButton/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Image, Button, Box } from '@chakra-ui/react';
import { useAtomValue } from 'jotai';
import { useEffect, useState } from 'react';

import { userAtom } from '@/atom';

Expand All @@ -12,8 +13,13 @@ const GOOGLE_LOGIN_URL =

const GoogleLoginButton = () => {
const user = useAtomValue(userAtom);
const [isMounted, setIsMounted] = useState(false);

if (user.isLogin) {
useEffect(() => {
setIsMounted(true);
}, []);

if (!isMounted || user.isLogin) {
return <Box h={{ base: '8', lg: '10', '2xl': '14' }} />;
}
return (
Expand Down

0 comments on commit 692c92d

Please sign in to comment.