我相信我正确地在persistCombineReducers()内部传递了“ reducer”以及“ config”来创建一个持久存储。但是我遇到一个错误,说-'商店没有有效的减速器'
import { createStore } from 'redux'
import { persistStore, persistCombineReducers } from 'redux-persist'
import storage from 'redux-persist/es/storage'
...
const reducer = (state=initialState, action) => {
switch(action.type){
...
}
}
...
export const store =
createStore(persistCombineReducers(config, reducer), initialState)
export const persistor = persistStore(store)
...
我希望这家商店能够长期存在。而是会引发错误-“商店没有有效的减速器”
答案 0 :(得分:1)
使用persistReducer
代替persistCombineReducers
。
PersistReducer
用于只有1个reducer并以一个函数为参数,而persistCombineReducers
以一个对象为参数(一个包含减速器列表的对象)的情况。