Skip to content

Instantly share code, notes, and snippets.

@asherccohen
Created June 19, 2019 17:18
Show Gist options
  • Save asherccohen/837b0a2f842b4b9637a72a4e64e64b18 to your computer and use it in GitHub Desktop.
Save asherccohen/837b0a2f842b4b9637a72a4e64e64b18 to your computer and use it in GitHub Desktop.
// events/reducer.js
const initialState = { todos: [] };
export const eventsReducer = (state = initialState, action) => {
switch(action.type) {
case 'GET_EVENTS_REQUEST':
return { ...state, isFetching: true };
case 'GET_EVENTS_SUCCESS':
return { ...state, isFetching: false, todos: action.payload };
case 'GET_EVENTS_FAILURE':
return { ...state, isFetching: false, errorMessage: action.payload.message };
default:
return state;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment