Skip to content

Instantly share code, notes, and snippets.

@wojciech-bilicki
Last active September 2, 2017 10:21
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 wojciech-bilicki/79bb3db7d2244c4c5e1b61ed7d0b0f95 to your computer and use it in GitHub Desktop.
Save wojciech-bilicki/79bb3db7d2244c4c5e1b61ed7d0b0f95 to your computer and use it in GitHub Desktop.
#73 store.js refactor
import { SET_SEARCH_TERM } from './actionCreators';
const DEFAULT_STATE = {
searchTerm: ''
};
const setSearchTerm = (state, action) => ({
...state,
searchTerm: action.payload
});
const rootReducer = (state = DEFAULT_STATE, action) => {
switch (action.type) {
case SET_SEARCH_TERM:
return setSearchTerm(state, action);
default:
return state;
}
};
export default rootReducer;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment