Last active
January 16, 2018 20:27
-
-
Save jacobp100/d21cccc5e2bc1b77076e283503e6e694 to your computer and use it in GitHub Desktop.
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
| const defaultState = { search: '', results: [] } | |
| const store = createStore((state = defaultState, action) => { | |
| switch (action.type) { | |
| case 'SET_SEARCH': | |
| return { ...state, search: action.search, results: [] } | |
| case 'ADD_RESULTS': | |
| return { ...state, results: state.results.concat(action.results) } | |
| default: | |
| return state | |
| } | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment