Search code examples
reactjsreact-nativeexporeact-native-screens

How to make screens appear only after installation in react native expo


I have a few welcome screens that should only appear once, when the app is first launched after installation, but I have no idea how.

My app is in react-native 0.64.3 and expo 43.0.2

Thank you in advance


Solution

  • AsyncStorage will do the job for you, you can use it along with componentDidMount

    async componentDidMount() {
      const firstTime = await AsyncStorage.getItem("isFirstTime")
      if(firstTime != null) {
        // navigate to HomePage directly
      } else {
        // navigate to other screens where you have some infos to show
        await AsyncStorage.setItem("isFirstTime", 'true')
      }
    }