Created
June 6, 2017 19:30
-
-
Save tricoder42/196bee534bba4d3a9f079efdb0fc6e4b to your computer and use it in GitHub Desktop.
2017/06/06 [Medium] Use Selectors in Redux for Great Good
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
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