Skip to content

Commit

Permalink
[#1] feat : dataRedux 생성
Browse files Browse the repository at this point in the history
- action 생성
- actionTypes 생성
- reducer 생성
- selectort 생성
  • Loading branch information
JeongBin0227 committed Jan 6, 2021
1 parent 2aa0446 commit 5f7bea8
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/data/users/actionTypes.tsx
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';
7 changes: 7 additions & 0 deletions src/data/users/actions.tsx
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,
};
}
27 changes: 27 additions & 0 deletions src/data/users/reducers.tsx
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
}
}
1 change: 1 addition & 0 deletions src/data/users/selectors.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const getUser = (state) => state.user;

0 comments on commit 5f7bea8

Please sign in to comment.