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 themeReducer from '../Theme/themeReducer'
|
7
|
|
8
|
|
9
|
// Store holds shared state in the application
|
10
|
const store = createStore(
|
11
|
combineReducers({ user: userReducer, theme: themeReducer }),
|
12
|
applyMiddleware(thunk) // Thunk middleware so we can async fetch data from the api
|
13
|
)
|
14
|
|
15
|
export default store
|
16
|
export const persistor = persistStore(store)
|
17
|
export type AppStore = typeof store
|
18
|
export type RootState = ReturnType<typeof store.getState>
|
19
|
export type AppDispatch = typeof store.dispatch
|