Skip to content

Instantly share code, notes, and snippets.

@smhatre59
Created November 5, 2016 07:27
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 smhatre59/1fb71003a952bca0c2f68714304716f9 to your computer and use it in GitHub Desktop.
Save smhatre59/1fb71003a952bca0c2f68714304716f9 to your computer and use it in GitHub Desktop.
export default function reducer(state={
users:[],
fetching: false,
fetched: false,
error: null
}, action){
switch (action.type) {
case "FETCH_USERS":{
return {...state, fetching: true}
}
case "FETCH_USERS_FULFILLED":{
return {
...state,
fetching: false,
fetched: true,
users:action.payload
}
}
case "FETCH_USERS_REJECTED":{
return {
...state,
fetching: false,
error: action.payload
}
}
}
return state;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment