Skip to content

Instantly share code, notes, and snippets.

@rafael-metractive
Created April 20, 2019 00:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafael-metractive/7cf14adf1f88ea15d7759a52627b8e13 to your computer and use it in GitHub Desktop.
Save rafael-metractive/7cf14adf1f88ea15d7759a52627b8e13 to your computer and use it in GitHub Desktop.
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