import React, { useState } from 'react';
import { View, Text, Button, ActivityIndicator, StyleSheet } from 'react-native';
export default function ApiConnectionDemo() {
const [data, setData] = useState(null);
const [loading, setLoading] = useState(false);
const [error, setError] = useState(null);
// TODO: Add function to fetch data from backend API
return (
<View style={styles.container}>
<Text style={styles.title}>API Connection Demo</Text>
<Button title="Fetch Data" onPress={() => { /* TODO: call fetch function */ }} />
{loading && <ActivityIndicator size="large" color="#0000ff" />}
{error && <Text style={styles.error}>{error}</Text>}
{data && <Text style={styles.data}>{data}</Text>}
</View>
);
}
const styles = StyleSheet.create({
container: { flex: 1, padding: 20, justifyContent: 'center' },
title: { fontSize: 24, marginBottom: 20, textAlign: 'center' },
data: { marginTop: 20, fontSize: 16, textAlign: 'center' },
error: { marginTop: 20, fontSize: 16, color: 'red', textAlign: 'center' }
});