I am fetching data(content and image) from an api, and render it to a flatlist, whenever I load the app it is always slow and take a while before it display the rendered data, how can I fix it, I will appreciate if you work on my code, to provide the answer and also if you will recommend a dependency make sure it work with expo see my below code.
URL = 'https://placewave.com/avatar';
const [Data, setData] = React.useState([]);
useEffect(() => {
axios.get('https://placewave.com/alluser')
.then((response) => setData(response.data))
.catch(error => { console.log(error) });
}, []);
<FlatList
data = {Data}
keyExtractor={item => item.id}
showsVerticalScrollIndicator = {false}
renderItem={({item}) => {
return (
<Image
source={{ uri: URL + '/' + item.user_image}}
resizeMode="cover"
style={styles.userImage}
/>
<Text>{item.user_name}</Text>
)
}}
/>
Thank you.