redux-persist reports: Cannot read property "getItem" of undefined and Cannot read property" setItem" of undefined
write according to the tutorial
const persistConfig = {
key: "root",
storageSession,
stateReconciler: autoMergeLevel2
};
function configureStore () {
const persistedReducer = persistCombineReducers(persistConfig, rootReducer);
const store = createStore(persistedReducer, applyMiddleware(thunk));
const persistor = persistStore(store);
return {store, persistor};
}
module.exports = configureStore;
introduce PersistGate components
ReactDOM.render
(
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<Router history={history}>
{routes}
</Router>
</PersistGate>
</Provider>
, document.getElementById("app_root")
);
the answer given on the official website is: customize any storage api, that conforms to the standard to implement the following method: setItem getItem removeItem. (note: these methods must support promises.)
but I don"t know where to add these api,. Which god can help me solve it?