Skip to content

Instantly share code, notes, and snippets.

@jacobp100
Last active January 16, 2018 20:27
Show Gist options
  • Select an option

  • Save jacobp100/d21cccc5e2bc1b77076e283503e6e694 to your computer and use it in GitHub Desktop.

Select an option

Save jacobp100/d21cccc5e2bc1b77076e283503e6e694 to your computer and use it in GitHub Desktop.
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