Created
October 24, 2023 07:21
-
-
Save tanat/cf85edcdac87b6c059ea0d016c4ade19 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { combineReducers, configureStore } from '@reduxjs/toolkit' | |
import logger from 'redux-logger' | |
import { useDispatch, TypedUseSelectorHook, useSelector } from 'react-redux' | |
import { api } from '@/api' | |
import { tagsSlice } from './slices/tagsSlice' | |
import { additionalServicesSlice } from './slices/additionalServicesSlice' | |
import { regionsSlice } from './slices/regionsSlice' | |
import { searchSlice } from './slices/searchSlice' | |
const rootReducer = combineReducers({ | |
tags: tagsSlice.reducer, | |
regions: regionsSlice.reducer, | |
search: searchSlice.reducer, | |
additionalServices: additionalServicesSlice.reducer, | |
[api.reducerPath]: api.reducer | |
}) | |
export type AppState = ReturnType<typeof rootReducer> | |
export function initializeStore(preloadedState: any = {}) { | |
return configureStore({ | |
reducer: rootReducer, | |
preloadedState, | |
middleware: (getDefaultMiddleware) => | |
getDefaultMiddleware({ serializableCheck: false }) | |
.concat(api.middleware), | |
}) | |
} | |
export type AppDispatch = ReturnType<typeof initializeStore>["dispatch"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment