Skip to content

Instantly share code, notes, and snippets.

@agustinfece
Created June 18, 2021 19:18
Show Gist options
  • Save agustinfece/d2af11af4a1de3a78b89421309af22f7 to your computer and use it in GitHub Desktop.
Save agustinfece/d2af11af4a1de3a78b89421309af22f7 to your computer and use it in GitHub Desktop.
App.js
import { StatusBar } from 'expo-status-bar';
import React, { useEffect } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import AsyncStorage from '@react-native-async-storage/async-storage';
export default function App() {
const getTheme = async () => {
try {
const value = await AsyncStorage.getItem('theme');
console.log('value', value);
} catch(error) {
console.log('error', error);
};
};
const setTheme = async () => {
try {
await AsyncStorage.setItem('theme', 'dark');
} catch(error) {
console.log('error', error);
};
};
useEffect(() => {
setTheme();
}, []);
return (
<View style={styles.container}>
<Text>Open up App.js to start working on your app!</Text>
<StatusBar style="auto" />
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment