-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- action 생성 - actionTypes 생성 - reducer 생성 - selectort 생성
- Loading branch information
1 parent
2aa0446
commit 5f7bea8
Showing
4 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const RESET_AUTH = 'RESET_AUTH'; | ||
export const SET_AUTH = 'SET_AUTH'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import * as ActionTypes from '../../data/rootActionTypes'; | ||
|
||
export function logout() { | ||
return { | ||
type: ActionTypes.RESET_AUTH, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import * as ActionTypes from '../../data/rootActionTypes' | ||
|
||
const initialState: UserState = { | ||
users: [ | ||
{ | ||
id: 1, | ||
name: '최범수', | ||
}, | ||
{ | ||
id: 2, | ||
name: '김정빈', | ||
}, | ||
], | ||
} | ||
|
||
export default function user(state = initialState, action) { | ||
switch (action.type) { | ||
case ActionTypes.SET_AUTH: | ||
return action.user | ||
|
||
case ActionTypes.RESET_AUTH: | ||
return null | ||
|
||
default: | ||
return state | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const getUser = (state) => state.user; |