Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/store/authStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ export const useAuthStore = create<AuthState>()(
checkLoginStatus: () => {
const token = getCookie('auth_token');
set((state) => {
return { ...state, isLoggedIn: !!token };
if (!token) {
return { ...state, isLoggedIn: false, user: null };

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

immer의 produce를 적용한다면

import produce from "immer";

const newState = produce(state, (draft) => {
draft.isLoggedIn = false;
draft.user = null;
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

단점은 타이핑이 어렵습니다.

}
return { ...state, isLoggedIn: true };
});
},
}),
Expand Down
Loading