Last active
April 5, 2019 13:41
-
-
Save JeromeFranco/15d8f64101b94265616343b967d7161d 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
import { createSlice } from 'redux-starter-kit'; | |
const todoSlice = createSlice({ | |
slice: 'todos', | |
initialState: [], | |
reducers: { | |
addTodo(state, action) => [ ...state, action.payload], | |
removeTodo(state, action) => state.filter(todo => todo !== action.payload), | |
}, | |
}); | |
// Extract the action creators object and the reducer | |
export const { actions, reducer } = todoSlice; | |
// Export the reducer, either as a default or named export | |
export default reducer; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment