-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstore.ts
34 lines (32 loc) · 972 Bytes
/
store.ts
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
import { combineReducers, configureStore } from "@reduxjs/toolkit";
import productReducer from "./namesapces/products/store/feats/productsSlice";
import {
persistStore,
persistReducer,
FLUSH,
REHYDRATE,
PAUSE,
PERSIST,
PURGE,
REGISTER,
} from "redux-persist";
import storage from "redux-persist/lib/storage";
import cartReducer from "./namesapces/cart/store/store";
const reducers = combineReducers({
products: productReducer,
cart: cartReducer,
});
const persistConfig = {
key: "root",
storage,
whiteList: ["cart"],
backlist: ["products"],
};
const persistedReducer = persistReducer(persistConfig, reducers);
export const store = configureStore({
reducer: persistedReducer,
});
// Infer the `RootState` and `AppDispatch` types from the store itself
export type RootState = ReturnType<typeof store.getState>;
// Inferred type: {posts: PostsState, comments: CommentsState, users: UsersState}
export type AppDispatch = typeof store.dispatch;