-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathstate.js
More file actions
40 lines (35 loc) · 879 Bytes
/
state.js
File metadata and controls
40 lines (35 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// redux 로그인 상태 관리 파일입니다.
import { createSlice, configureStore } from '@reduxjs/toolkit';
// 초기 상태 정의
const initialState = {
isLoggedIn: false,
userEmail: '',
userName: '',
serverPath: 'http://localhost:8080/',
};
// 슬라이스 생성
const authSlice = createSlice({
name: 'auth',
initialState,
reducers: {
setLoggedIn(state, action) {
state.isLoggedIn = action.payload;
},
setUserEmail(state, action) {
state.userEmail = action.payload;
},
setUserName(state, action) {
state.userName = action.payload;
},
},
});
// 액션 및 리듀서 추출
export const { setLoggedIn, setUserEmail, setUserName } = authSlice.actions;
const authReducer = authSlice.reducer;
// 스토어 생성
const store = configureStore({
reducer: {
auth: authReducer,
},
});
export default store;