Skip to content

Commit

Permalink
refactor(#97): refetch 대신에 enabled 수정하기
Browse files Browse the repository at this point in the history
  • Loading branch information
naarang committed Nov 27, 2024
1 parent c628b11 commit ef7c6a2
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions apps/frontend/src/page/login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ function RouteComponent() {

const [, set] = useLocalStorage({ key: 'token', initialValue: '' });

const { data: token, error: loginError } = useLoginQuery({ code });
const { data, error: loginError } = useLoginQuery({ code });

const { data: user, error: userInfoError, refetch } = useQuery(userQueryOptions.info());
const { data: user, error: userInfoError } = useQuery({
...userQueryOptions.info(),
enabled: !!data?.token
});

useEffect(() => {
if (token?.token) {
set(token.token);
refetch();
}
}, [token, set, refetch]);
if (data?.token) set(data.token);
}, [set, data]);

if (loginError || userInfoError) throw new Error('유저 정보 조회에 실패했습니다.');

Expand Down

0 comments on commit ef7c6a2

Please sign in to comment.