【问题标题】:White flashes and white screen of death after the app opening after adding redux-persist添加redux-persist后应用打开后白闪白屏死机
【发布时间】:2019-11-07 00:49:56
【问题描述】:

在添加redux-persist 后第二次打开应用程序后,我得到白闪和白屏死机。 “redux-persist”的版本是“^5.10.0”。

这是我的App.js 文件:

    import { PersistGate } from 'redux-persist/integration/react'
    import {store, persistor } from './redux/store'

    export default class App extends React.Component {

  renderLoading = ()=> {
    <View>
      <ActivityIndicator size="large"/>
    </View>  
  }

      render() {
        return( 
          <Provider store={store}>
            <PersistGate loading={this.renderLoading()} persistor={persistor}>
              <AppContainer/>
            </PersistGate>
          </Provider>
        )  
      }
    }

这是我的 ./redux/store 文件:

import { createStore, applyMiddleware } from 'redux'
import { AsyncStorage } from 'react-native'
import thunkMiddleware from 'redux-thunk'
import { persistStore, persistReducer } from "redux-persist"
import reducers from './index';

import bindAuthEvents from '../auth/redux/bindEvents';
import bindTrackingEvents from '../tracking/redux/bindEvents';

const persistConfig = {
    key: 'root',
    storage: AsyncStorage,
  }

const persistedReducer = persistReducer(persistConfig, reducers)

const createStoreWithMiddleware = applyMiddleware(thunkMiddleware)(createStore);

export const store = createStoreWithMiddleware(persistedReducer);

const dispatch = event => store.dispatch(event) 
const getState = () => store.getState()

bindAuthEvents(dispatch, getState);
bindTrackingEvents(dispatch, getState);

export const persistor = persistStore(store);

可能是什么问题?以及如何解决?

【问题讨论】:

    标签: react-native redux redux-persist


    【解决方案1】:

    我遇到了这个问题,但我使用加载组件解决了。

    在模拟器中它最终会发生,但在物理设备中不会。

    【讨论】:

      猜你喜欢
      • 2023-02-01
      • 2020-07-12
      • 1970-01-01
      • 2021-03-18
      • 2011-02-24
      • 1970-01-01
      • 2012-01-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多