Skip to content

Instantly share code, notes, and snippets.

@corsonknowles
Created October 4, 2018 20:55
Show Gist options
  • Save corsonknowles/13f0dc23bff143340bbf9e0cd06661dd to your computer and use it in GitHub Desktop.
Save corsonknowles/13f0dc23bff143340bbf9e0cd06661dd to your computer and use it in GitHub Desktop.
Put this in your Reducers folder and include it in your root reducer with combineReducers();
import { RECEIVE_ERRORS, CLEAR_ERRORS } from '../actions/errorActionCreators';
// Note: Unlike in other reducers, errors are stored in a simple array
const defaultState = () => [];
const ErrorsReducer = (state = defaultState(), action) => {
Object.freeze(state);
switch (action.type) {
case RECEIVE_ERRORS:
return action.errors;
case CLEAR_ERRORS:
return [];
default:
return state;
}
};
export default ErrorsReducer;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment