Skip to content

Commit

Permalink
refactor(store): remove deprecated createStore method
Browse files Browse the repository at this point in the history
  • Loading branch information
pl-buiquang authored May 4, 2023
1 parent aa1efa8 commit 4b45df9
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions src/state/store.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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)

0 comments on commit 4b45df9

Please sign in to comment.