/App.js Secret
Created
June 18, 2021 19:18
App.js
This file contains 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 { 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