Skip to content

Instantly share code, notes, and snippets.

@tricoder42
Created June 6, 2017 19:30
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 tricoder42/196bee534bba4d3a9f079efdb0fc6e4b to your computer and use it in GitHub Desktop.
Save tricoder42/196bee534bba4d3a9f079efdb0fc6e4b to your computer and use it in GitHub Desktop.
2017/06/06 [Medium] Use Selectors in Redux for Great Good
const initialState = {
todos: []
}
const reducer = (state = initialState, action = {}) => {
if (action.type === 'ADD_TODO') {
return {
...state,
todos: [...state.todos, action.payload]
}
}
return state
}
const allTodos = (state) => state.todos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment