Ignite: rehydrate/load from asyncstorage too slow?

Created on 1 Dec 2016  路  5Comments  路  Source: infinitered/ignite

hello. i use some ignite stuff in an app i develop. i have the loginredux and loginsaga similar to the base ignite app. i have an if isLoggedIn to show the login screen otherwise show another screen. i log in in the beginning, then close the app. next time i open it, i get the login screen for a few milliseconds and then it jumps to the main screen. i console logged some stuff, and it seems like the login data is loaded but a bit later than the first render. how can i fix that? how can i get more info about it?

Most helpful comment

while I do not know specifically in the context of ignite, the traditional way to solve this problem is to render a loading state until persistence has completed. You can do this either by

  1. have one of your reducers store when boostrap is complete
persistStore(store, config, () => {
  store.dispatch({ type: BOOTSTRAP_COMPLETE })
})
// in some reducer
case BOOTSTRAP_COMPLETE: 
  return {...state, boostraped: true}

then show a loading state until sate.boostraped === true

  1. use react lifecycle to delay render (https://github.com/rt2zz/redux-persist/blob/master/docs/recipes.md#delay-render-until-rehydration-complete)

All 5 comments

while I do not know specifically in the context of ignite, the traditional way to solve this problem is to render a loading state until persistence has completed. You can do this either by

  1. have one of your reducers store when boostrap is complete
persistStore(store, config, () => {
  store.dispatch({ type: BOOTSTRAP_COMPLETE })
})
// in some reducer
case BOOTSTRAP_COMPLETE: 
  return {...state, boostraped: true}

then show a loading state until sate.boostraped === true

  1. use react lifecycle to delay render (https://github.com/rt2zz/redux-persist/blob/master/docs/recipes.md#delay-render-until-rehydration-complete)

aha. i will try both and see. thanks :)

ok i did the first thing you suggested and it worked. should i maybe make a pr to include this in the startup redux part of ignite?

ok i actually made a pr. it was small enough to do it quickly today.

see #582 and #715 .

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rammmukul picture rammmukul  路  3Comments

TitanKing picture TitanKing  路  3Comments

GantMan picture GantMan  路  3Comments

GantMan picture GantMan  路  3Comments

NikitaVr picture NikitaVr  路  3Comments