All files / app/store configureStore.prod.ts

0% Statements 0/16
100% Branches 0/0
0% Functions 0/1
0% Lines 0/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22                                           
import { RootState, createRootReducer, persistConfig } from '.';
import { createStore, applyMiddleware } from '@reduxjs/toolkit';
import { getInitialStateFromDisk } from '@utils/disk-store';
import { routerMiddleware } from 'connected-react-router';
import { createHashHistory } from 'history';
import { persistReducer, persistStore } from 'redux-persist';
import thunk from 'redux-thunk';
 
export const history = createHashHistory();
const rootReducer = createRootReducer({ history, keys: getInitialStateFromDisk() });
const router = routerMiddleware(history);
const enhancer = applyMiddleware(thunk, router);
 
export function configureStore(initialState?: RootState) {
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
  const persistedReducer = persistReducer(persistConfig, rootReducer as any);
  const store = createStore(persistedReducer, initialState, enhancer);
  const persistor = persistStore(store);
 
  return { store, persistor };
}