1
|
|
2
|
import { applyMiddleware, combineReducers, createStore } from 'redux'
|
3
|
import { persistStore } from 'redux-persist'
|
4
|
import thunk from 'redux-thunk'
|
5
|
import userReducer from '../Auth/userSlice'
|
6
|
import { catalogReducer } from '../Catalog/catalogSlice'
|
7
|
import themeReducer from '../Theme/themeReducer'
|
8
|
|
9
|
|
10
|
// Store holds shared state in the application
|
11
|
const store = createStore(
|
12
|
combineReducers({ user: userReducer, theme: themeReducer, catalog: catalogReducer }),
|
13
|
applyMiddleware(thunk) // Thunk middleware so we can async fetch data from the api
|
14
|
)
|
15
|
|
16
|
export default store
|
17
|
export const persistor = persistStore(store)
|
18
|
export type AppStore = typeof store
|
19
|
export type RootState = ReturnType<typeof store.getState>
|
20
|
export type AppDispatch = typeof store.dispatch
|