Skip to content

Instantly share code, notes, and snippets.

@JeromeFranco
Last active April 5, 2019 13:41
Show Gist options
  • Save JeromeFranco/15d8f64101b94265616343b967d7161d to your computer and use it in GitHub Desktop.
Save JeromeFranco/15d8f64101b94265616343b967d7161d to your computer and use it in GitHub Desktop.
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