diff options
author | 2022-05-22 13:49:12 +0100 | |
---|---|---|
committer | 2022-05-22 13:49:12 +0100 | |
commit | 994bc43d488eefc0ee39f39dd7fae5515322b17b (patch) | |
tree | 64872194dbcc1112f1850dd94fd4c3185c1a6d6f /App.js | |
parent | 853aefca82243a574e3fd8d5e5c7270355ba0cdb (diff) | |
download | notes_mobile-994bc43d488eefc0ee39f39dd7fae5515322b17b.tar.gz notes_mobile-994bc43d488eefc0ee39f39dd7fae5515322b17b.tar.bz2 notes_mobile-994bc43d488eefc0ee39f39dd7fae5515322b17b.zip |
move api & helpers to utils
Diffstat (limited to 'App.js')
-rw-r--r-- | App.js | 51 |
1 files changed, 0 insertions, 51 deletions
@@ -1,51 +0,0 @@ -import { StatusBar } from 'expo-status-bar' -import { StyleSheet, SafeAreaView, Text } from 'react-native' -import { useState, useEffect } from 'react' -import AsyncStorage from '@react-native-async-storage/async-storage' -import Main from './components/Main' -import Login from './components/Login' - -export default function App() { - const [session, setSession] = useState() - const [error, setError] = useState(null) - - const showError = (e) => { - setError(e) - setTimeout(() => { setError(null) }, 2000) - } - - useEffect(() => { - AsyncStorage.getItem('session') - .then(session => setSession(JSON.parse(session))) - .catch(() => setSession(null)) - }, []) - - if (error || session === undefined) return ( - <SafeAreaView style={styles.container}> - {error - ? <Text style={styles.error}>{error}</Text> - : <Text>Loading...</Text>} - </SafeAreaView> - ) - - return ( - <SafeAreaView style={styles.container}> - { - session === null - ? <Login setSession={setSession} showError={showError} /> - : <Main session={session} setSession={setSession} showError={showError} /> - } - <StatusBar style="auto" /> - </SafeAreaView> - ) -} - -const styles = StyleSheet.create({ - container: { - flex: 1, - backgroundColor: '#000', - }, - error: { - color: 'red', - } -}) |