title: How to detect application first launch in react native app?
body: <p>In my scenario, I am having three different screens like <code>Page1</code>, <code>Page2</code>, <code>Page3</code>. Here, if the user last visited page 2 then next time if user open application, instead of showing page1 need to show page2. How to achieve this using a <code>react-native</code> application?</p>
  
  <p>I tried by using <code>async</code> storage but don’t know how to manage multiple pages </p>
  
  <pre><code>AsyncStorage.getItem("alreadyLaunched").then(value =&gt; {
              if(value == null){
                   AsyncStorage.setItem('alreadyLaunched', true); // No need to wait for `setItem` to finish, although you might want to handle errors
                   this.setState({firstLaunch: true});
              }
              else{
                   this.setState({firstLaunch: false});
              }}) // Add some error handling, also you can simply do this.setState({fistLaunch: value == null})
  </code></pre>
  
  <p>App.js</p>
  
  <pre><code>import { createAppContainer } from 'react-navigation';
  import { createStackNavigator} from 'react-navigation-stack';
  
  import FirstPage from './pages/FirstPage';
  import SecondPage from './pages/SecondPage';
  import ThirdPage from './pages/ThirdPage';
  
  //import all the screens we are going to switch 
  const App = createStackNavigator({
     //Constant which holds all the screens like index of any book 
     FirstPage: { screen: FirstPage, header: null},
     SecondPage: { screen: SecondPage,  headerLeft: null, headerBackTitle: null}, 
     ThirdPage: { screen: ThirdPage}, 
    },
    {
      initialRouteName: 'FirstPage',
    }
  );
  export default createAppContainer(App);
  </code></pre>