Home > Enterprise >  backgroundImage React Native not working with flatlist not showing me the images
backgroundImage React Native not working with flatlist not showing me the images

Time:05-12

i need to show the images on my screen with the element flatlist

const renderItem = ({ item }) => (
        <ImageBackground
            source={{ uri: item.imageUrl }}
            imageStyle={{
                borderRadius: 6,
                resizeMode: 'contain'
            }}
        />
    );
    return (<FlatList data={coursesData} renderItem={renderItem} keyExtractor={(item) => item.id} />);

CodePudding user response:

I see a few issues:

  1. Why are you using ImageBackground instead of just Image? ImageBackground is intended for use as a background.
  2. If the source of your image is a url you must specify an image height and width.
  3. give Flatlist style={{ flex: 1 }}, this will allow it to take up all the space it needs.
  • Related