From 4b45df9f9c216c073a0387fe18d7c223f226fd04 Mon Sep 17 00:00:00 2001 From: Paul Bui-Quang Date: Thu, 4 May 2023 15:42:25 +0200 Subject: [PATCH] refactor(store): remove deprecated createStore method --- src/state/store.ts | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/state/store.ts b/src/state/store.ts index 2ec33f6d5..23fc288bd 100644 --- a/src/state/store.ts +++ b/src/state/store.ts @@ -1,8 +1,8 @@ import { createStateSyncMiddleware, initStateWithPrevTab } from 'redux-state-sync' -import { createStore, applyMiddleware, combineReducers } from 'redux' -import { composeWithDevTools } from 'redux-devtools-extension' +import { combineReducers } from 'redux' import { persistReducer, persistStore } from 'redux-persist' import thunkMiddleware from 'redux-thunk' +import { configureStore } from '@reduxjs/toolkit' import logger from 'redux-logger' import localforage from 'localforage' @@ -54,17 +54,18 @@ const persistConfig = { const persistedReducer = persistReducer(persistConfig, rootReducer) -export const store = createStore( - persistedReducer, - composeWithDevTools( - applyMiddleware( - thunkMiddleware, - logger, - createStateSyncMiddleware({ - predicate: (action) => action.type == 'autoLogout/open' || action.type == 'autoLogout/close' - }) - ) - ) -) +export const store = configureStore({ + reducer: persistedReducer, + middleware: (getDefaultMiddleware) => + getDefaultMiddleware() + .prepend( + thunkMiddleware, + createStateSyncMiddleware({ + predicate: (action) => action.type == 'autoLogout/open' || action.type == 'autoLogout/close' + }) + ) + .concat(logger) +}) + initStateWithPrevTab(store) export const persistor = persistStore(store)