AppLoading setsate life cycle


#1

I have no idea about AppLoading demo.

https://docs.expo.io/versions/latest/sdk/app-loading.html

why after restart the app, the state is still ready?

how should we reset this state?


#2

I do not understand your problem, can u explain mote about your project, or share a code?

About de demo:
In the demo we have a function _cacheResourcesAsync, this function is responsable to load all assets,for example, images, fonts, etc.
This functions is passed to AppLoading component.

<AppLoading
startAsync={this._cacheResourcesAsync}
onFinish={() => this.setState({ isReady: true })}
onError={console.warn}
/>

When this function completes the loads AppLoading component trigger onFinish event that trigger () => this.setState({ isReady: true }) arrow function.

this arrow function changes de state to isReady: true. this.setState() runs render() again

render() {
  if (!this.state.isReady) {
 // ... AppLoading code
  }
// ... Your App Code
}

The next execution of the code will return “Your App Code” instead “AppLoading code”.
While “AppLoading code” are returned the app stays on Splash Screen, then when render return “Your App Code”, user wee see Your code rendered on the screen.

@singleseeker i hope i’ve helped you.


#3

@victorwads Good job. Save my life.


closed #4

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.