import counter from './modules/user'

// Specify the modules that need to be persisted const persistedModules = ['counter']

// Create a new reducer that only persists the specified modules const rootReducer = (state: any, action: any) => { if (persistedModules.includes(action.type)) { return persistedReducer(state, action) } return state }

// Create persistedReducer that only persists the specified modules const persistedReducer: any = persistReducer( { key: 'root', storage, whitelist: persistedModules, }, rootReducer

重新更改这一段代码import counter from modulesuser 指定需要持久化存储的模块const persistedModules = counter 创建一个新的reducer只持久化存储指定的模块const rootReducer = state any action any = if persistedModulesincludesactiontype ret

原文地址: http://www.cveoy.top/t/topic/iXHB 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录