AppLoading setsate life cycle

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?

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.

2 Likes

@victorwads Good job. Save my life.

1 Like

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