parent
5caa3895db
commit
06575e0ed3
@ -0,0 +1,12 @@
|
||||
import React from 'react'
|
||||
import App from './App'
|
||||
import store from './src/redux/store'
|
||||
import { Provider } from 'react-redux'
|
||||
|
||||
export default function Index(){
|
||||
return(
|
||||
<Provider store={store}>
|
||||
<App />
|
||||
</Provider>
|
||||
)
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,24 @@
|
||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit"
|
||||
import { User } from "../../core/user";
|
||||
|
||||
interface currentUserState {
|
||||
value: User[]
|
||||
}
|
||||
|
||||
const initialState: currentUserState = {
|
||||
value: [],
|
||||
}
|
||||
|
||||
export const currentUserSlice = createSlice({
|
||||
name: "currentUser",
|
||||
initialState,
|
||||
reducers: {
|
||||
loginUser: (state, action: PayloadAction<User>) => {
|
||||
state.value.push(action.payload);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const { loginUser } = currentUserSlice.actions
|
||||
|
||||
export default currentUserSlice.reducer;
|
@ -0,0 +1,18 @@
|
||||
import { configureStore } from "@reduxjs/toolkit";
|
||||
import currentUserReducer from "./features/currentUserSlice";
|
||||
import { getDefaultMiddleware } from '@reduxjs/toolkit';
|
||||
|
||||
const customizedMiddleware = getDefaultMiddleware({
|
||||
serializableCheck: false
|
||||
})
|
||||
|
||||
const store = configureStore({
|
||||
reducer: {
|
||||
currentUser: currentUserReducer,
|
||||
},
|
||||
middleware: (getDefaultMiddleware) => customizedMiddleware,
|
||||
})
|
||||
|
||||
export type RootState = ReturnType<typeof store.getState>;
|
||||
export type AppDispatch = typeof store.dispatch;
|
||||
export default store;
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue