Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 如何使用persistStore()持久化存储?我面临一个错误';存储区没有有效的减速机';_Reactjs_React Native_Redux_Redux Persist - Fatal编程技术网

Reactjs 如何使用persistStore()持久化存储?我面临一个错误';存储区没有有效的减速机';

Reactjs 如何使用persistStore()持久化存储?我面临一个错误';存储区没有有效的减速机';,reactjs,react-native,redux,redux-persist,Reactjs,React Native,Redux,Redux Persist,我相信我正确地将persistCombineReducers()中的“reducer”与“config”一起传递,以创建一个持久存储。但我面临一个错误,即“存储区没有有效的缩减器” import { createStore } from 'redux' import { persistStore, persistCombineReducers } from 'redux-persist' import storage from 'redux-persist/es/storage' ...

我相信我正确地将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)

...

我希望商店能持续经营下去。相反,它会抛出一个错误——“存储没有有效的还原程序”

使用
persistReducer
而不是
persistCombineReducer


PersistReducer
用于只有一个reducer,并将函数作为参数,而
persistCombineReducer
将对象作为参数(包含一个reducer列表的对象)

您是否引用了persist store npm文档@SureshKumarAriya是的,Suresh!有什么想法吗?在persistCombineReducers(config,reducer)中,尝试用包含您的reducer的对象替换reducer,或者用persistcombinereducer替换函数(因为您现在没有组合任何东西)@hardwarker非常感谢!我不知道“持久减速器”,它帮助了cause@DivyatejaDanny没问题:)如果有人有同样的问题,我会加上它作为答案