Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6211

How to detect application first launch in react native app?

$
0
0

In my scenario, I am having three different screens like Page1, Page2, Page3. 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 react-native application?

I tried by using async storage but don’t know how to manage multiple pages

AsyncStorage.getItem("alreadyLaunched").then(value => {            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})

App.js

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);

Viewing all articles
Browse latest Browse all 6211

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>