Created
September 19, 2021 16:11
-
-
Save majirosstefan/579b7b4e4cd632a660f7727d1c4dd312 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// import AsyncStorage | |
// from '@react-native-async-storage/async-storage'; | |
const LOCALE_KEY = 'locale'; | |
export const storeLocale = async locale => { | |
try { | |
console.log('PERSIST LOCALE', locale); | |
await AsyncStorage.setItem(LOCALE_KEY, locale); | |
} catch (error) { | |
// Error saving data | |
console.error(error); | |
} | |
}; | |
export const retrieveLocale = async () => { | |
try { | |
return await AsyncStorage.getItem(LOCALE_KEY); | |
} catch (error) { | |
console.error(error); | |
return null; | |
} | |
}; | |
export const deleteLocale = async () => { | |
try { | |
return await AsyncStorage.removeItem(LOCALE_KEY); | |
} catch (error) { | |
console.error(error); | |
return null; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment