Please provide the following:
- SDK Version: 46
- Platforms:Android
- expo-image-picker
I’m trying to display multiples images on en FlatList but when I try to render the images I get the warning "Key 'uri’Preformatted text
in the image picker result is deprecated and will be removed in SDK 48, you can access selected assets through the “assets” array instead
Here is my code
import React, { Component,useState } from “react”;
import { Button, View, Text,FlatList,StyleSheet,useWindowDimensions,Image,Alert,ActivityIndicator } from “react-native”;
import * as ImagePicker from ‘expo-image-picker’;
//
export default function AboutScreen()
{;
const[images,setImages] = useState();
const[isLoading,setLoading] = useState(false);
const {width} = useWindowDimensions();
const pickImages = async () => {
setLoading(true);
let result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.images,
allowsMultipleSelection:true,
selectionLimit:10,
aspect: [4,3],
quality: 1,
})
console.log(result);
setLoading(false);
if(!result.canceled)
{
setImages(result.uri ? [result.uri] : result.selected);
// also tried result.assets[0].uri //
}
};
return (
<FlatList
data = {images}
renderItem={({item}) =>(
<Image source={{uri: item.uri}}
style ={{width:width,height:250}}
/>
)}
numColumns={2}
keyExtractor={(item) => item.uri}
contentContainerStyle={{marginVertical:50,paddingBottom:100}}
ListHeaderComponent={
isLoading ? (
<Text style={{alignContent:‘center’, fontSize:20,fontWeight:‘bold’}} >cargando…
<ActivityIndicator size={“large”} />
) : (
)
}
/>
);
}