简体   繁体   中英

I want to return images in flatlist from an array that contians links/urls for images react-native

I want to return images in flatlists. first of all this array qwer[] contains url links the images init it evens console.logs it gets the links from an api. i have manually tried putting images in View tag with the source and it works. but when i do with with flatlists it shows no error but doesnot display images. Can u help me please?

return(
    <FlatList 
    horizontal
    showsHorizontalScrollIndicator={false}
    data={qwer}
    renderItem={({ item }) => (
        <Image 
            source={({uri:item})}
            style={{
                width:260,
                height:300,
                borderWidth:2,
                borderColor:'#d35647',
                resizeMode:'contain',
                margin:8
            }}
        />
    )}
/>

In your code just replace

 source={({uri:item})}

to

source={{uri : item}}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM