Skip to content

Commit e092d00

Browse files
committed
feat: 로그인 정보를 저장할 zustand persist store 구현
1 parent f9350f4 commit e092d00

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/stores/loginInfo.store.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { create } from 'zustand';
2+
import { persist } from 'zustand/middleware';
3+
4+
import { Authenticated, Registration } from '@type/models';
5+
6+
type LoginInfo = Authenticated | Registration;
7+
type LoginInfoState = {
8+
loginInfo: LoginInfo | null;
9+
setLoginInfo: (loginInfo: LoginInfo | null) => void;
10+
};
11+
12+
export const useLoginInfoStore = create(
13+
persist<LoginInfoState>(
14+
(set) => ({
15+
loginInfo: null,
16+
setLoginInfo: (loginInfo) => set({ loginInfo }),
17+
}),
18+
{
19+
name: 'LOGIN_INFO_PERSIST',
20+
}
21+
)
22+
);

0 commit comments

Comments
 (0)