Where to perform startup tasks?


#1

When using the AppLoading component, is there a standard way of loading some startup activities? I see the example in the doc here: https://docs.expo.io/versions/latest/sdk/app-loading.html#app-loading

I was hoping to perform startup tasks using redux/saga, but if the AppLoading component is the first component loaded then that means the redux store won’t be available.

Wondering how others are doing this with redux, or if at all. Thanks.


#2

Well it is a React component, so you could look at componentWillMount?


#3

Thanks Edgar, that’s what I’m doing now, but I was hoping to do something like:

  1. Use AppLoading component to load from /assets, fonts, etc
  2. Keep the AppLoading component on the screen, but now start using react-redux and to do some other actions
  3. Move on to the App’s screen

Initially I was hoping to wrap the component with , but according to the Expo doc AppLoading has to be the first component so that idea is out.

Just wondering how others are handling this sort of thing.


#4

@robotron Right now I am asking myself the same than you. How did you do it finally?


#5

It’s been a while but I ended up doing something like this:

state = {
    expoReady: false,
  };

  componentWillMount() {
    this.loadResources();
  }

  async loadResources() {

    await Expo.Font.loadAsync({
        // do some loading
    });

    this.setState({ expoReady: true });
  }

  render() {
    if (!this.state.expoReady) {
      return (
        <AppLoading />
      );
    }

    return (
      <Provider store={store}>
        <View style={styles.container}>
          <ReduxNavigation />
        </View>
      </Provider>
    );
  }
}