Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { configureStore, getDefaultMiddleware } from "@reduxjs/toolkit";
import { createBrowserHistory } from "history";
import { connectRouter, routerMiddleware } from "connected-react-router";
import rootReducer from "./rootReducer";
const history = createBrowserHistory();
const middleware = getDefaultMiddleware({
// TODO: a few reducers are not correctly immutable or serializable. Fix those and turn this back on
// emoticonPicker is one
immutableCheck: false,
serializableCheck: false
});
const store = configureStore({
reducer: connectRouter(history)(rootReducer),
middleware: [routerMiddleware(history), ...middleware]
});
if (process.env.NODE_ENV === "development" && module.hot) {
module.hot.accept("./rootReducer", () => {
const newRootReducer = require("./rootReducer").default;
store.replaceReducer(newRootReducer);
});
import { AnyAction, configureStore, getDefaultMiddleware } from '@reduxjs/toolkit'
import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux'
import rootReducer from 'reducers'
const middlewares = getDefaultMiddleware({
serializableCheck: false, // warn: in order to use the global ConfirmDialog, disable the serializableCheck check
})
const genStore = () => {
if (process.env.NODE_ENV === 'development') {
const { createLogger } = require('redux-logger')
const logger = createLogger({
predicate: (_: any, action: AnyAction) => {
if (action.type.includes('pending')) {
return false
}
return true
},
})
key: "connectionStatus",
storage: sensitiveStorage,
stateReconciler: hardSet,
blacklist: ["connectStatus", "apiInitialized"]
};
const rootReducer = combineReducers({
authCredentials: persistReducer(authPersistConfig, authReducer),
connectionStatus: persistReducer(connectPersistConfig, connectReducer),
});
const persistedReducer = persistReducer(rootPersistConfig, rootReducer);
const store = configureStore({
reducer: persistedReducer,
middleware: getDefaultMiddleware({
serializableCheck: {
// Ignore actions from redux-persist
ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER]
}
})
})
const persistor = persistStore(store, null, () => {
store.dispatch(initApiClient())
});
export type RootState = ReturnType
export const useSelector: TypedUseSelectorHook = useReduxSelector
export { store, persistor };
configureStore,
DeepPartial,
EnhancedStore,
getDefaultMiddleware,
Store,
ThunkDispatch,
} from "@reduxjs/toolkit";
import { render, RenderOptions, RenderResult } from "@testing-library/react";
import { Provider } from "react-redux";
import configureMockStore from "redux-mock-store";
import { reducers } from "./src/modules";
import type { AppState } from "./src/store";
import { theme } from "./src/theme";
import { thunkErrorHandler } from "./src/middlewares/thunk-error-handler";
const middlewares = getDefaultMiddleware({
immutableCheck: false,
serializableCheck: false,
});
export const createReduxStore = (
preloadedState?: Partial
): EnhancedStore => {
return configureStore({
reducer: reducers,
middleware: [...middlewares, thunkErrorHandler],
preloadedState,
});
};
const store = createReduxStore();
const baseState = store.getState();
public initializeStore() {
const loggerMiddleware = createLogger({ collapsed: true });
const preloadedState = this.getBrowserInitialState();
const middlewares = [
...getDefaultMiddleware({
thunk: {
extraArgument: {
axios: getAxiosInstance(),
},
},
}),
ReduxNotifier,
setUserToTracker,
];
if (EnvChecker.isLocal() || EnvChecker.isDev()) {
middlewares.push(loggerMiddleware);
}
return configureStore({
reducer: rootReducer,
middleware: middlewares,
public static getStore(extraArgument: ThunkExtraArgument) {
return configureStore({
reducer: rootReducer,
devTools: false,
preloadedState: initialState,
middleware: [
...getDefaultMiddleware({
thunk: {
extraArgument,
},
}),
],
});
}
}