In development environment, I noticed that with each reload that the app was slow. So I did some testing, and by removing PersistGate, the app loads easily, and without any slowness.
cfgStore:
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import { persistStore, persistReducer } from 'redux-persist';
import storage from 'redux-persist/lib/storage';
import reducers from './combineStore';
const persistConfig = {
key: 'root',
storage,
};
const cfgStore = () => {
const middlewares = [thunk];
const enhancer = applyMiddleware(...middlewares);
const persistedReducer = persistReducer(persistConfig, reducers);
// create store
return createStore(persistedReducer, enhancer);
};
export const persistor = persistStore(cfgStore());
export default cfgStore;
index.js
// ...
export default class App extends Component {
componentDidMount(){
SplashScreen.hide()
}
render() {
// ...
return (
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<StatusBar
backgroundColor={mainStyle.principalBackColor}
barStyle="dark-content"
/>
<Loader loading={loader}/>
<RouterWithRedux>
<Scene key='root'>
<Scene
component={List}
// initial={isLoggedIn && token}
initial={true}
hideNavBar={true}
key='List'
title='List'
/>
</Scene>
</RouterWithRedux>
</PersistGate>
</Provider>
)
}
}
My stack:
react-native 0.54.4
react-native-router-flux ^4.0.0-beta.28
react-redux ^5.0.7
redux-persist ^5.9.1
redux-thunk ^2.2.0
I faced the same issue
@adhenrique how did you resolved this issue?
Having the same problem. Could anyone pinpoint to a solution?
Any hint here ?
why this one is closed? facing same issue
Having the same problem. Any solutions?
It's been 1 year since I posted this problem here. I will try to run it again, and I will comment again here.
if I'm not mistaken, it was something related to configuration ...
@adhenrique did you find something?
I created this feature request, I don't know if it's possible, but I'll surely look it this weekend.
https://github.com/rt2zz/redux-persist/issues/1094
version 6 has timeout option in config and you can reduce 5 seconds to whatever you want (risking you state not being properly hydrated I guess)
version 6 has
timeoutoption in config and you can reduce 5 seconds to whatever you want (risking you state not being properly hydrated I guess)
what's the meaning of timeout?
Most helpful comment
@adhenrique how did you resolved this issue?