我在项目中设置了一个redux-presist,并且正在store.js文件中实现,但是给了我错误提示,如图所示,storage.getitem不是函数,当我更改时,错误已消除storage:storage,但是当我尝试执行storage:AsyncStorage时,会出现此错误。
这是我的代码
import { createStore,applyMiddleware } from 'redux'
import { persistStore, persistReducer } from 'redux-persist'
import reducers from '../reducers'
import AsyncStorage from 'react-native'
const persistConfig = {
//...
key: 'root',
storage:AsyncStorage
}
const persistedReducer = persistReducer(persistConfig, reducers)
export default () => {
const store = createStore(persistedReducer,{},applyMiddleware())
const persistor = persistStore(store)
return { store, persistor }
}