import React, { useState, useEffect } from 'react'; import { StyleSheet, Text, View, FlatList, ActivityIndicator } from 'react-native'; const dataURL = "https://gist.githubusercontent.com/andteki/91c74e1ae7f292ec02f100e09fe52c7f/raw/487f4dd6e0e9da0bab6e8920b1c3b9f2c6b70e8f/test.json" export default function App() { const [isLoading, setLoading] = useState(true); const [data, setData] = useState([]); const [title, setTitle] = useState([]); const [desc, setDesc] = useState([]); useEffect(() => { fetch(dataURL) .then((response) => response.json()) .then((data) => { setData(data.friends); setTitle(data.title); setDesc(data.desc); }) .catch((error) => alert(error)) .finally(()=>setLoading(false)); }, []); return ( {isLoading ? ( ) : ( {title} id} renderItem={({item}) => ( {item.name} - {item.age} )} /> {desc} )} ); } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#fff', alignItems: 'center', justifyContent: 'center', marginTop: 25, }, friend: { fontSize: 22, }, title: { fontSize: 30, fontWeight: "bold", }, desc: { textAlign: "center", marginBottom: 100, color: "#333", } });