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

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))
}
 
PREVIOUS NEXT
Tagged: #app #save #passing #screen #user #passed #test #app #exits #react #native
ADD COMMENT
Topic
Name
8+3 =