Skip to content

Commit

Permalink
Add: 유저 전역 상태 관리
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee JaeJun committed Feb 1, 2024
1 parent 2b3c075 commit 70d52a8
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/recoil/authState.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { atom } from 'recoil';
import { recoilPersist } from 'recoil-persist';

export type Nullable<T> = T | null;

interface User {
memberId: Nullable<number>;
email: Nullable<string>;
nickname: Nullable<string>;
image: Nullable<string>;
loggedIn: boolean;
}

const { persistAtom } = recoilPersist({
key: 'bc-member',
storage: sessionStorage,
});

export const authState = atom<User>({
key: 'authState',
default: {
memberId: null,
email: null,
nickname: null,
image: null,
loggedIn: false,
},
effects_UNSTABLE: [persistAtom],
});

0 comments on commit 70d52a8

Please sign in to comment.