big change

This commit is contained in:
Luke Berndt
2022-12-30 21:41:58 -05:00
parent 953a3eac40
commit 3970dd6b79
5 changed files with 120 additions and 20 deletions

View File

@@ -1,27 +1,21 @@
// https://github.com/supasate/connected-react-router
// configureStore.js
import { createBrowserHistory } from 'history'
import { applyMiddleware, compose, createStore } from 'redux'
import { routerMiddleware } from 'connected-react-router'
import createRootReducer from './reducers'
import thunk from 'redux-thunk';
export const history = createBrowserHistory()
import { apiSlice } from '../features/api/apiSlice'
export default function configureStore(preloadedState) {
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(
createRootReducer(history), // root reducer with router state
preloadedState,
composeEnhancers(
applyMiddleware(
routerMiddleware(history), // for dispatching history actions
thunk,
// ... other middlewares ...
),
),
)
import { configureStore } from '@reduxjs/toolkit'
export default function configureAppStore(preloadedState) {
const store = configureStore({
reducer: {
[apiSlice.reducerPath]: apiSlice.reducer
},
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware().concat(apiSlice.middleware),
preloadedState
})
return store
}

View File

@@ -6,11 +6,13 @@ import systemReducer from "../System/system-reducer"
import talkgroupReducer from "../Talkgroups/talkgroup-reducer"
import groupReducer from "../Group/group-reducer"
import callReducer from "../Call/call-reducer"
import { apiSlice } from '../features/api/apiSlice'
export default (history) => combineReducers({
router: connectRouter(history),
system: systemReducer,
talkgroup: talkgroupReducer,
group: groupReducer,
call: callReducer
call: callReducer,
[apiSlice.reducerPath]: apiSlice.reducer
})