Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

want the app to save the passing screen after a user has passed the test even when the app exits in 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>
   );
}
 
PREVIOUS NEXT
Tagged: #app #save #passing #screen #user #passed #test #app #exits #react #native
ADD COMMENT
Topic
Name
2+8 =