-
-
Save codebucks27/aab3cc2991fcb322fd70c4fefb6b0836 to your computer and use it in GitHub Desktop.
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
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