Skip to content

Instantly share code, notes, and snippets.

@majirosstefan
Created September 19, 2021 16:11
Show Gist options
  • Save majirosstefan/579b7b4e4cd632a660f7727d1c4dd312 to your computer and use it in GitHub Desktop.
Save majirosstefan/579b7b4e4cd632a660f7727d1c4dd312 to your computer and use it in GitHub Desktop.
// 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