I have <flatlist /> Component in application homepage, I tried to put an <Image /> above it but it not displayed.It seems In my case React Native just shown the last component.I have tested it by putting <Image /> after <flatlist /> and the image displayed without problem but as i told flatlist vanished Cause thats wasn't the last component in home Function class, So here is my Homepage code
import React from 'react';
import {StyleSheet,View,Text,Image,FlatList} from 'react-native';
const DATA = [
{
id: '1',
title: 'Icon 1',
image: 'https://example.com/icon1.png',
},
{
id: '2',
title: 'Icon 2',
image: 'https://example.com/icon2.png',
},
{
id: '3',
title: 'Icon 3',
image: 'https://example.com/icon3.png',
},
{
id: '4',
title: 'Icon 4',
image: 'https://example.com/icon4.png',
},
];
export default function Home(){
return(
<Image style={styles.banner} source={{uri: 'https://example.com/banner.jpg'}} />,
<FlatList
data={DATA}
numColumns={'2'}
keyExtriactor={(item) => item.id}
renderItem={({ item }) => {
return (
<View style={styles.container}>
{item.image && (
<Image style={styles.image} source={{ uri: item.image }}></Image>
)}
{item.title && (
<Text>{item.title}</Text>
)}
</View>
);
}}
/>
);
}
const styles = StyleSheet.create({
container:{
marginTop:20,
padding:20,
},
image:{
width:70,
height:50,
},
banner:{
width:400,
height:200,
marginTop:10
}
})