ssap_app/App.js

41 lines
906 B
JavaScript

import React, { useEffect, useState } from "react";
import { View, ActivityIndicator } from "react-native";
import { getDID, clearAll } from "./src/services/storage";
import AppNavigator from "./src/navigation/AppNavigator";
export default function App() {
const [did, setDidState] = useState(null);
const [loading, setLoading] = useState(true);
useEffect(() => {
const init = async () => {
const saved = await getDID();
setDidState(saved);
setLoading(false);
};
init();
}, []);
const handleReset = async () => {
await clearAll();
setDidState(null);
};
if (loading) {
return (
<View style={{ flex: 1, justifyContent: "center" }}>
<ActivityIndicator size="large" />
</View>
);
}
return (
<AppNavigator
did={did}
onRegistered={(newDid) => setDidState(newDid)}
onReset={handleReset}
/>
);
}