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