Skip to content

Instantly share code, notes, and snippets.

@gilankpam
Last active May 29, 2017 00:07
Show Gist options
  • Select an option

  • Save gilankpam/7c5d0891858b7fbba45e51d3ef635cad to your computer and use it in GitHub Desktop.

Select an option

Save gilankpam/7c5d0891858b7fbba45e51d3ef635cad to your computer and use it in GitHub Desktop.
const initialState = {
loading: false,
user: null,
error: null
}
export default function (state = initialState, action) {
switch(action.type) {
case 'LOGIN_REQUEST':
return {
...state,
loading: true
}
case 'LOGIN_SUCCESS':
return {
...state,
loading: false,
user: action.user
}
case 'LOGIN_FAILURE':
return {
...state,
loading: false,
error: action.error
}
default:
return state
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment