Skip to main content

ActivityIndicator

設定Activity Indicator

import React, {useState, useEffect} from 'react';
import {Text, StyleSheet, View, ActivityIndicator} from 'react-native';

const MyScreen = () => {
const [loading, setLoading] = useState(false);
const [projects, setProjects] = useState([]);
useEffect(()->{
loadData();
}, []);
const loadData() = async () =>{
setLoading(true);
const response = await apiProjects.getProjects();
setLoading(false);
setProjects(response.data.data);
}

return (
<View>
<ActivityIndicator animating={loading} size="large" />
<FlatList
data={projects}
keyExtractor={(item) => item.projectID}
renderItem={({item}) =>{
return <Text>{item.projectName}</Text>
}}
/>
</View>
);

}

export default MyScreen;