Skip to content

Instantly share code, notes, and snippets.

@codebucks27
Last active April 22, 2021 09:31
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 codebucks27/aab3cc2991fcb322fd70c4fefb6b0836 to your computer and use it in GitHub Desktop.
Save codebucks27/aab3cc2991fcb322fd70c4fefb6b0836 to your computer and use it in GitHub Desktop.
import { createSlice } from "@reduxjs/toolkit";
const initialState = [];
const addTodoReducer = createSlice({
name: "todos",
initialState,
reducers: {
//here we will write our reducer
//Adding todos
addTodos: (state, action) => {
state.push(action.payload);
return state;
},
},
});
export const { addTodos } = addTodoReducer.actions;
export const reducer = addTodoReducer.reducer;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment