The title pretty much says it all (lol). My code is as follows:
import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View, Image, Button} from 'react-native';
import { useState } from 'react';
import * as ImagePicker from 'expo-image-picker';
import { FlatList } from 'react-native';
export default function ExpoImagePicker() {
const [image, setImage] = useState(null);
const pickImage = async () => {
let result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.All,
allowsMultipleSelection:true,
aspect: [1,1],
quality: 1,
});
console.log(result);
if (!result.canceled) {
setImage(result.assets.uri);
}
}
return (
<Flatlist
contentContainerStyle = {{justifyContent:'center', alignItems:'center'}}
horizontal
data={setImage}
renderItem={({ item }) => (
<Image source = {{uri: item}} style = {{width: 280, height: 280}}></Image>
)}
keyExtractor={(item, index) => index.toString()}
ListFooterComponent={() => <Button title = "Pick From Media Library" onPress= {pickImage} style={{display:'flex', flex: 1, justifyContent:'center', alignItems: 'center'}}> </Button>}
/>
);
}
I’ve tried searching the error message via Google and I put the import { Flatlist } line separately as well