Ignite: Wait AsyncStorage to load navigation

Created on 7 Oct 2016  路  6Comments  路  Source: infinitered/ignite

How can I wait to my store sync to AsyncStorage to mount my navigation?
the problem is: when I'm logged my first screen is home and when I'm not is login screen.

I will appreciate any help.
thanks!

Most helpful comment

I'll make this a task, and see if I can get an IR dev to add it to Ignite.

All 6 comments

My favorite way of solving this is to have a screen that shows before both, that will redirect to the correct one.

If you make this screen look like your splash image, then no one will notice. ALSO, it gives you a chance to fade-out your splash image or do anything fancy, you might want to do visually.

A little animation on this screen is pretty good for a primary loading screen.

Good tip man! but how you get the state synchronously?
I mean, the app startup in splash the first time and how you know if the AsyncStorage already return to show the correct screen?

make sure your initial reduce shape is always different from what could be stored.

For instance. Have userLoggedIn INITIAL_STATE be null. Now when it flips to true/false you know you're dealing with useful data.

I see, but if is the first time that I open the App and the userLoggedIn is really null?
You have some example or open source app that you can share with me?
Big thanks!

I'll make this a task, and see if I can get an IR dev to add it to Ignite.

There's a couple issues around ReduxPersist timing. We're going to have a closer look at this when it comes time to fix it up for Ignite 2.0. Thank you.

Was this page helpful?
0 / 5 - 0 ratings