Projekt

Obecné

Profil

Stáhnout (1.16 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

    
10
const composeEnhancers = composeWithDevTools({})
11

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

    
27
export default store
28
export const persistor = persistStore(store)
29
export type AppStore = typeof store
30
export type RootState = ReturnType<typeof store.getState>
31
export type AppDispatch = typeof store.dispatch
    (1-1/1)