Last active
July 27, 2017 14:29
-
-
Save sandwichsudo/a6d89aa88c0f0db093145d88a6a849ef to your computer and use it in GitHub Desktop.
Reducer case to update the error when request completes.
This file contains hidden or 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
// src/containers/RepoSearchPage/reducer/RepoSearchReducer.js | |
import { actionTypes } from '../RepoSearchConstants'; | |
const initialState = { | |
results: [], | |
error: '' | |
}; | |
export default (state = initialState, action) => { | |
switch (action.type) { | |
case actionTypes.UPDATE_RESULTS: { | |
return { ...state, results: action.items }; | |
} | |
case actionTypes.REQUEST_COMPLETE: { | |
return { ...state, error: action.error }; | |
} | |
default: | |
return state; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment