我在persist-store和react-redux上有问题,在添加persist-redux之前,应用程序运行正常。 在控制台上启动:
[Fri Oct 23 2020 13:13:00.546] LOG redux-persist/stateReconciler: rehydrated keys 'dishes, comments, promotions, leaders, favorites, _persist'
[Fri Oct 23 2020 13:13:03.400] LOG Error
[Fri Oct 23 2020 13:13:03.420] ERROR [SyntaxError: JSON Parse error: Unexpected EOF]
reduces,store和persistent-store的配置在以下文件中
import { createStore, applyMiddleware } from "redux";
import thunk from "redux-thunk";
// import logger from "redux-logger";
import { persistStore, persistCombineReducers } from "redux-persist";
import AsyncStorage from "@react-native-community/async-storage";
...
export const ConfigureStore = () => {
const config = {
key: "root",
storage: AsyncStorage,
debug: true,
};
const reducers = persistCombineReducers(config, {
...
});
const store = createStore(reducers, applyMiddleware(thunk));
const persistor = persistStore(store);
return { persistor, store };
};
还有App.js文件:
import React, { Component } from "react";
import Main from "./components/MainComponent";
import { Provider } from "react-redux";
import { ConfigureStore } from "./redux/configureStore";
import { PersistGate } from "redux-persist/integration/react";
import { Loading } from "./components/LoagingComponent";
const { persistor, store } = ConfigureStore();
export default class App extends Component {
render() {
return (
<Provider store={store}>
<PersistGate loading={<Loading />} persistor={persistor}>
<Main />
</PersistGate>
</Provider>
);
}
}
请帮助,我已经很长一段时间在想什么了,我找不到解决方法