Skip to content

Commit bdbae88

Browse files
Add files via upload
1 parent 0ce8ce5 commit bdbae88

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

Day4/redux/store.jsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { configureStore } from "@reduxjs/toolkit";
2+
import userReducer from './userSlice'
3+
export default configureStore({
4+
reducer :{
5+
user:userReducer,
6+
}
7+
});

Day4/redux/userSlice.jsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { createSlice } from "@reduxjs/toolkit";
2+
3+
export const userSlice=createSlice({
4+
name:"user",
5+
initialState:{
6+
user:null
7+
},
8+
reducers:{
9+
login:(state,action)=>{
10+
state.user=action.payload;
11+
},
12+
logout:(state)=>{
13+
state.user=null;
14+
}
15+
}
16+
})
17+
export const {login,logout}=userSlice.actions;
18+
19+
export const selectUser=(state)=>state.user.user;
20+
21+
export default userSlice.reducer;

0 commit comments

Comments
 (0)