“Deseja que o aplicativo salve a tela que passa depois que um usuário passar no teste, mesmo quando o aplicativo sair no React Native” Respostas de código

Deseja que o aplicativo salve a tela que passa depois que um usuário passar no teste, mesmo quando o aplicativo sair no React Native

import AsyncStorage from '@react-native-async-storage/async-storage';

// or whatever
const key = "hasPassed"

export const hasPassed = async () => {
    return AsyncStorage.getItem(key).then(result => result != null ? JSON.parse(result) : undefined).catch(e => console.log(e))    
}

export const setHasPassed = async (newPassed) => {
    return AsyncStorage.setItem(key, JSON.stringify({hasPassed: newPassed})).catch(e => console.log(e))
}
SAMER SAEID

Deseja que o aplicativo salve a tela que passa depois que um usuário passar no teste, mesmo quando o aplicativo sair no React Native

if(count<5) {
  //  Alert.alert('pass','pass');
  // showing passing screen in the form of a modal
   setHasPassed(true).then(() => setshowpass(true))
}
SAMER SAEID

Deseja que o aplicativo salve a tela que passa depois que um usuário passar no teste, mesmo quando o aplicativo sair no React Native

// or whatever name it is
const MainScreen = () => {

   const [showpass, setshowpass] = useState();
   
   useEffect(() => {
       const getState = async () => {
           const result = await hasPassed()
           setshowpass(result ? result.hasPassed : false)
       }
       getState()
   }, [])

   // since it is async
   if (showpass === undefined) {
      return null
   }

   return (
      <View style={styles.body}>
        <Modal
           transparent={false}
           visible={showpass}
           animationType='slide'
           hardwareAccelerated 
         >
            <View style={styles.body}>
              <Text style={styles.toptext}>Congratulations!</Text>
              <Text style={styles.toptext}>Worked great in Turkishya!</Text>
              <Text style={styles.topptext}>
                And mastered the skill 'Alphabets'
              </Text>
            </View>
            </Modal>
      <View>
   );
}
SAMER SAEID

Respostas semelhantes a “Deseja que o aplicativo salve a tela que passa depois que um usuário passar no teste, mesmo quando o aplicativo sair no React Native”

Perguntas semelhantes a “Deseja que o aplicativo salve a tela que passa depois que um usuário passar no teste, mesmo quando o aplicativo sair no React Native”

Mais respostas relacionadas para “Deseja que o aplicativo salve a tela que passa depois que um usuário passar no teste, mesmo quando o aplicativo sair no React Native” em JavaScript

Procure respostas de código populares por idioma

Procurar outros idiomas de código