Skip to content

Commit

Permalink
ModalSliceを作成しよう
Browse files Browse the repository at this point in the history
  • Loading branch information
s-yoshiii committed Sep 7, 2022
1 parent a87f6c9 commit 44620b2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/features/modal/ModalSlice.js
@@ -0,0 +1,20 @@
import { createSlice } from "@reduxjs/toolkit";
const initialState = {
isOpen: false,
};

const modalSlice = createSlice({
name: "modal",
initialState,
reducers: {
openModal: (state, action) => {
state.isOpen = true;
},
closeModal: (state, action) => {
state.isOpen = false;
},
},
});

export const { openModal, closeModal } = modalSlice.actions;
export default modalSlice.reducer;
2 changes: 2 additions & 0 deletions src/store.js
@@ -1,8 +1,10 @@
import { configureStore } from "@reduxjs/toolkit";
import cartReducer from "./features/cart/CartSlice";
import modalReducer from "./features/modal/ModalSlice";

export const store = configureStore({
reducer: {
cart: cartReducer,
modal: modalReducer,
},
});

0 comments on commit 44620b2

Please sign in to comment.