reactjs - 实施redux-persist后反应本机应用程序保持空白?
问题描述
每个人
我正在尝试使用 redux-persist 来持久化我的商店,但是在将它实施到我的 app.js 之后,我得到了白屏,我寻找了这个错误,我唯一能找到的就是清除 componentDidMount() 甚至这对我不起作用:
应用程序.js:
import React from 'react';
import { AppLoading, Asset, Font } from 'expo';
import { PersistGate } from 'redux-persist/integration/react';
import { Ionicons } from '@expo/vector-icons';
import { Provider } from 'react-redux';
import storeConfig from './config/store';
import RootNavigation from './navigation/RootNavigation';
import Splash from './screens/Splash'
const {persistor, store} = storeConfig();
// 普通代码
render() {
if (!this.state.isLoadingComplete ) {
return (
<AppLoading
startAsync={this._loadResourcesAsync}
onError={this._handleLoadingError}
onFinish={this._handleFinishLoading}
/>
);
} else {
return (
<Provider store={store}>
<PersistGate loading={<Splash /> } persistor={persistor}>
<RootNavigation />
</PersistGate>
</Provider>
);
}
}
商店.js:
import { createStore } from 'redux';
import { persistStore, persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'
import logger from 'redux-logger';
import reducers from '../reducers';
const persistConfig = {
key: 'root',
storage,
};
const pReducer = persistReducer(persistConfig, reducers);
export const store = createStore(pReducer);
export const persistor = persistStore(store);
解决方案
推荐阅读
- flutter - 如何制作可调整大小的TextField?
- javascript - 如何在节点 js 中写入 xls 文件和流以响应
- r - dplyr:计算每天的账户余额
- html - 在 HTML/CSS 中覆盖浏览器默认字体 - 但不是代码字体?
- ios - 创建可重用的 UIView 子类 - 遇到大小问题
- swift - 如何快速执行一个函数 5 秒
- android - Android:运行测试用例时:无法确定任务':app:compileDebugAndroidTestJavaWithJavac'的依赖关系
- python - 如何将 self 参数传递给 python cProfile
- reactjs - 应用 find() 时获得 2 个渲染而不是 1 个渲染
- reactjs - React 构建文件不适用于共享主机