Skip to content

Instantly share code, notes, and snippets.

@sandwichsudo
Last active July 27, 2017 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sandwichsudo/a6d89aa88c0f0db093145d88a6a849ef to your computer and use it in GitHub Desktop.
Save sandwichsudo/a6d89aa88c0f0db093145d88a6a849ef to your computer and use it in GitHub Desktop.
Reducer case to update the error when request completes.
// 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