Created
April 20, 2019 00:46
-
-
Save rafael-metractive/7cf14adf1f88ea15d7759a52627b8e13 to your computer and use it in GitHub Desktop.
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
const USER_SET = 'USER_SET' | |
const USER_SET_LOADING = 'USER_SET_LOADING' | |
const USER_LOGOUT = 'USER_LOGOUT' | |
const initialState = { | |
loading: false, | |
userData: {} | |
} | |
export default function user (state = initialState, action = {}) { | |
switch (action.type) { | |
case USER_SET: | |
console.log('USER SET', action) | |
return Object.assign({}, state, { ...action.payload }) | |
case USER_SET_LOADING: | |
return { ...state, loading: action.payload }; | |
case USER_LOGOUT: | |
return { | |
loading: false, | |
userData: {} | |
} | |
default: | |
return state | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment