1
|
import { configureStore } from "@reduxjs/toolkit"
|
2
|
import { persistStore, persistReducer, FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER} from "redux-persist"
|
3
|
import { combineReducers } from "redux"
|
4
|
import AsyncStorage from "@react-native-async-storage/async-storage"
|
5
|
import userReducer from "./reducers/userSlice"
|
6
|
import itemReducer from "./reducers/itemSlice"
|
7
|
import searchFormReducer from "./reducers/searchFormSlice"
|
8
|
import listViewReducer from "./reducers/listViewSlice"
|
9
|
import homePageReducer from "./reducers/homePageSlice"
|
10
|
import noteViewReducer from "./reducers/notesSlice"
|
11
|
import planViewReducer from "./reducers/planSlice"
|
12
|
|
13
|
const persistConfig = {
|
14
|
key: "root",
|
15
|
storage: AsyncStorage,
|
16
|
whitelist: ["user"],
|
17
|
}
|
18
|
|
19
|
const reducers = combineReducers({
|
20
|
user: userReducer,
|
21
|
itemViewState: itemReducer,
|
22
|
planViewState: planViewReducer,
|
23
|
noteViewState: noteViewReducer,
|
24
|
searchForm: searchFormReducer,
|
25
|
listView: listViewReducer,
|
26
|
homePage: homePageReducer
|
27
|
})
|
28
|
|
29
|
const persistedReducer = persistReducer(persistConfig, reducers)
|
30
|
|
31
|
export const store = configureStore({
|
32
|
reducer: persistedReducer,
|
33
|
middleware: (getDefaultMiddleware) =>
|
34
|
getDefaultMiddleware({
|
35
|
serializableCheck: {
|
36
|
ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER],
|
37
|
},
|
38
|
})
|
39
|
})
|
40
|
|
41
|
export const Persistor = persistStore(store)
|
42
|
|
43
|
export default { store, Persistor }
|
44
|
export type RootState = ReturnType<typeof store.getState>
|
45
|
export type AppStore = typeof store
|
46
|
export type AppDispatch = typeof store.dispatch
|