-1

I have a screen made with react-native-swiper where I give an introduction on how the app works, but I would like to display this screen only the first time the user opens the app.

how can I do this?

Paulo Rodrigues
  • 397
  • 4
  • 20
  • This site is not for 'how do I do this'? You need to research your own solution and show your work. If it does not work as expected, then ask how to fix it. https://stackoverflow.com/help/how-to-ask – Saeed D. Sep 25 '20 at 23:18

1 Answers1

0

you can store a bool value in a local storage, even in the secured store by using the expo SecureStore package. Then check the store for that value when the app starts.

import * as SecureStore from 'expo-secure-store';

const app = ()=>{
    useEffect(()=>{
       const getStoredValue = async ()=> {
         const introduction = await SecureStore.getItemAsync("introduction");
         //use this variable to determine if you want to run the introduction.
 
         //if introduction doesn't exist in the secure store create one 
         if (introduction === null ) {
             try {
                  SecureStore.setItemAsync("Introduction", true);
                 }
             catch (ex) {}
       }
       getStoredValue();
    },[]);
}
Wen W
  • 2,434
  • 1
  • 10
  • 15