import { Action , configureStore , getDefaultMiddleware , ThunkAction , } from '@reduxjs/toolkit' ; import { Context , createWrapper , MakeStore } from 'next-redux-wrapper' ; import { FLUSH , PAUSE , PERSIST , persistReducer , persistStore , PURGE , REGISTER , REHYDRATE , } from 'redux-persist' ; import storage from 'redux-persist/lib/storage' ; import rootReducer , { RootState } from './redux' ; const persistConfig = { key : 'root' , version : 1 , storage , } ; const persistedReducer = persistReducer ( persistConfig , rootReducer ) ; const store = configureStore ( { reducer : persistedReducer , devTools : true , middleware : getDefaultMiddleware ( { serializableCheck : { ignoredActions : [ FLUSH , REHYDRATE , PAUSE , PERSIST , PURGE , REGISTER ] , } , } ) , } ) ; ( store as any ) . __persistor = persistStore ( store ) ; const makeStore = ( context ) => store ; export const wrapper = createWrapper < RootState > ( makeStore , { debug : true } ) ; export type AppDispatch = typeof store . dispatch ; export type AppThunk = ThunkAction < void , RootState , unknown , Action < string > > ;