【发布时间】:2021-03-17 18:44:28
【问题描述】:
我正在使用redux-persist 来保持我的应用程序的状态。默认情况下,它在AsyncStorage 中保持状态,但我希望它在localStorage 中。就react-native 而言,官方文档中对此一无所知。
这是我到目前为止的代码:
import { persistStore, persistCombineReducers } from 'redux-persist';
import storage from 'redux-persist/es/storage';
const config = {
key: 'root',
storage,
debug: true
}
export const ConfigureStore = () => {
const store = createStore(
persistCombineReducers(config,{
dishes,
comments,
promotions,
leaders,
favorite
}),
applyMiddleware(thunk)
);
const persistor = persistStore(store)
return {persistor, store};
}
我可以这样做吗:
import storage from 'redux-persist/es/localStorage';
...
storage: storage
如果有人曾经使用过它,请帮助我解决这个问题。谢谢!
【问题讨论】:
标签: reactjs react-native redux redux-persist