Projekt

Obecné

Profil

Stáhnout (1.16 KB) Statistiky
| Větev: | Tag: | Revize:
1 37f6ff02 Vaclav Honzik
import { applyMiddleware, combineReducers, createStore } from 'redux'
2 a69da1e3 Vaclav Honzik
import { persistStore } from 'redux-persist'
3 37f6ff02 Vaclav Honzik
import thunk from 'redux-thunk'
4 8370b6c1 Vaclav Honzik
import userReducer from '../Auth/userSlice'
5 0d90d67b Vaclav Honzik
import themeReducer from '../Theme/themeSlice'
6 394f2d16 Vaclav Honzik
import catalogReducer from '../Catalog/catalogSlice'
7 1c710f4f Vaclav Honzik
import { composeWithDevTools } from 'redux-devtools-extension'
8 4f42fa52 Václav Honzík
import notificationReducer from '../Notification/notificationSlice'
9 c7d2ced1 Václav Honzík
10 1c710f4f Vaclav Honzik
const composeEnhancers = composeWithDevTools({})
11 8042e8b3 Vaclav Honzik
12 a69da1e3 Vaclav Honzik
// Store holds shared state in the application
13 c7d2ced1 Václav Honzík
const store = createStore(
14 1c710f4f Vaclav Honzik
    combineReducers({
15
        user: userReducer,
16
        theme: themeReducer,
17
        catalog: catalogReducer,
18 4f42fa52 Václav Honzík
        notification: notificationReducer
19 1c710f4f Vaclav Honzik
    }),
20
    process.env.REACT_APP_DEV_ENV === 'true'
21 0d90d67b Vaclav Honzik
        ? composeEnhancers( // ComposeEnhancers will inject redux-devtools-extension
22 1c710f4f Vaclav Honzik
              applyMiddleware(thunk) // Thunk middleware so we can async fetch data from the api
23
          )
24
        : applyMiddleware(thunk)
25 c7d2ced1 Václav Honzík
)
26
27
export default store
28 a69da1e3 Vaclav Honzik
export const persistor = persistStore(store)
29 c7d2ced1 Václav Honzík
export type AppStore = typeof store
30
export type RootState = ReturnType<typeof store.getState>
31
export type AppDispatch = typeof store.dispatch