Created
October 4, 2018 20:55
-
-
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();
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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