Last active
September 2, 2017 10:21
-
-
Save wojciech-bilicki/79bb3db7d2244c4c5e1b61ed7d0b0f95 to your computer and use it in GitHub Desktop.
#73 store.js refactor
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 { 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