Projekt

Obecné

Profil

Stáhnout (1 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/themeReducer'
6
import catalogReducer from '../Catalog/catalogSlice'
7
import { composeWithDevTools } from 'redux-devtools-extension'
8

    
9
const composeEnhancers = composeWithDevTools({})
10

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

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