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
export const RECEIVE_ERRORS = 'RECEIVE_ERRORS'; | |
export const CLEAR_ERRORS = 'CLEAR_ERRORS'; | |
export const receiveErrors = errors => ({ | |
type: RECEIVE_ERRORS, | |
errors, | |
}); | |
export const clearErrors = () => ({ | |
type: CLEAR_ERRORS, | |
}); |
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 []; |
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
/* eslint-disable no-undef, camelcase */ | |
import ReactOnRails from ‘react-on-rails’; | |
import { receiveErrors, clearErrors } from ‘./errorActionCreators’; | |
// protect your Reducers from silently failing by using constants | |
export const GET_ITEM = 'GET_ITEM'; | |
export const DELETE_ITEM = 'DELETE_ITEM'; | |
export const RECEIVE_ITEMS = 'RECEIVE_ITEMS'; |