Projekt

Obecné

Profil

Stáhnout (1.32 KB) Statistiky
| Větev: | Tag: | Revize:
1
import { applyMiddleware, combineReducers, createStore } from 'redux'
2
import { persistStore } from 'redux-persist'
3
import thunk from 'redux-thunk'
4
import userReducer from '../Auth/userSlice'
5
import themeReducer from '../Theme/themeSlice'
6
import catalogReducer from '../Catalog/catalogSlice'
7
import { composeWithDevTools } from 'redux-devtools-extension'
8
import notificationReducer from '../Notification/notificationSlice'
9
import trackingToolReducer from '../TrackingTool/trackingToolSlice'
10
import { enableMapSet } from 'immer'
11

    
12
enableMapSet()
13

    
14
const composeEnhancers = composeWithDevTools({})
15

    
16
// Store holds shared state in the application
17
const store = createStore(
18
    combineReducers({
19
        user: userReducer,
20
        theme: themeReducer,
21
        catalog: catalogReducer,
22
        notification: notificationReducer,
23
        trackingTool: trackingToolReducer
24
    }),
25
    process.env.REACT_APP_DEV_ENV === 'true'
26
        ? composeEnhancers( // ComposeEnhancers will inject redux-devtools-extension
27
              applyMiddleware(thunk) // Thunk middleware so we can async fetch data from the api
28
          )
29
        : applyMiddleware(thunk)
30
)
31

    
32
export default store
33
export const persistor = persistStore(store)
34
export type AppStore = typeof store
35
export type RootState = ReturnType<typeof store.getState>
36
export type AppDispatch = typeof store.dispatch
    (1-1/1)