Skip to content

Instantly share code, notes, and snippets.

@jonasantonelli
Created July 17, 2019 18:25
Show Gist options
  • Save jonasantonelli/569235eb1e332a3ce93598ef7cdcd030 to your computer and use it in GitHub Desktop.
Save jonasantonelli/569235eb1e332a3ce93598ef7cdcd030 to your computer and use it in GitHub Desktop.
Refactoring Reducer - First Version
import schema from './schema';
import { ACTIONS } from './action';
export default (state = schema, action) => {
switch (action.type) {
case ACTIONS.FETCHING:
return {
...state,
isFetching: true
};
case ACTIONS.FETCH_COMPLETE:
return {
...state,
...action.value,
isFetching: false
};
case ACTIONS.ERROR:
return {
...state,
isError: true,
errorMessage: action.errorMessage
};
default:
return state;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment