Skip to content

Instantly share code, notes, and snippets.

@Tauka
Created April 15, 2017 23:40
Show Gist options
  • Select an option

  • Save Tauka/03feced8cfe9706a238f2799700643d8 to your computer and use it in GitHub Desktop.

Select an option

Save Tauka/03feced8cfe9706a238f2799700643d8 to your computer and use it in GitHub Desktop.
export default function reducer(state={
data: [],
requestSuccess: false,
requestPending: false,
requestFail: false
}, action) {
switch(action.type) {
case "ACTION_PENDING": {
return {...state, requestPending: true}
}
case "ACTION_SUCCESS": {
return {...state, requestPending: false, requestSuccess: true, data: action.payload}
}
case "ACTION_FAIL": {
return {...state, requestPending: false, requestFail: true}
return state;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment