-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
43 lines (34 loc) · 1.07 KB
/
index.js
File metadata and controls
43 lines (34 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import React from "react";
import {createStore} from "redux";
import {configureStore, createSlice} from "@reduxjs/toolkit";
const initialCounterState ={counter :0,showCounter :true}
const counterSlice=createSlice({
name :"counter",
initialCounterState,
reducers:{
increment(state){return state.counter++ },
decrement(state){state.counter--},
toggle(state){state.showCounter=!state.showCounter},
increase(state,action){state.counter=state.counter+action.payload},
}
})
const initialAuthState ={
isAuthenticated :false
}
const authSlice=createSlice({
name :"authentication",
initialState :initialAuthState,
reducers:{
login (state){
state.isAuthenticated=true
},
logout(state){
state.isAuthenticated=false
}
}
})
const store =configureStore({reducer: {counter:counterSlice.reducer,auth :authSlice.reducer}
})
export const counterActions =counterSlice.actions
export const authActions =authSlice.actions
export default store