redux presist没有更新浏览器的本地存储



我的电子商务项目使用redux-persistent。

当我将我的应用程序更新到新版本时,我发现了一个新的错误。

我将initialState从数组更改为对象。

我在Chrome中的应用程序(我在上面测试并运行应用程序的浏览器(崩溃了!!因为我的initialState静态数组(NOT UPDATE(和新方法没有返回任何内容。(当然(。

但在Mozilla和其他浏览器中,我之前没有使用过我的应用程序!

为什么

我的商店配置:

import { createStore, applyMiddleware } from 'redux'
import { persistStore } from 'redux-persist'
import logger from 'redux-logger'
import RootReducer from './RootReducer'
const middleware = [logger]
export const store = createStore(RootReducer, applyMiddleware(...middleware))
export const persistore = persistStore(store)

我的rootReducer配置:

import { combineReducers } from 'redux'
import { persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'
import UserReducer from './User/UserReducer'
import ShoppingBagDropdownReducer from './ShoppingBagDropdown/ShoppingBagDropdownReducer'
import DirectoryReducer from './Directory/DirectoryReducer'
import ShopDataReducer from './ShopData/ShopDataReducer'
const persistConfig = {
key: 'root',
storage,
whileList: ['shoppingBagDropdown']
}

const rootReducer = combineReducers({
user: UserReducer,
shoppingBagDropdown: ShoppingBagDropdownReducer,
shopData: ShopDataReducer,
directory: DirectoryReducer
})
export default persistReducer(persistConfig, rootReducer)

是的:(

我找到了解决方案,那就是:用清除本地存储

localStorage.clear();

我看到你修复了它,但你也可以使用谷歌chrome在没有代码的情况下完成它。

CTRL + SHIFT + I > Application > Local Storage 

现在您只需要打开本地存储,右键单击并单击清除即可。

最新更新