I'm using react native and expo with an image picker. For some reason, my choosefromlibrary function is not setting the state so I can read it and insert the file location for viewing. Location is not necessary, I tried setImageLocation(result.uri) to no avail so I was just trying different things. result.uri prints with console.log, location prints with console.log, but when I console.log(imageSelected) nothing comes back
const [imageSelected, setImageSelected] = useState("");
const chooseFromLibrary = async () => {
let location = "";
let result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.All,
allowsEditing: true,
aspect: [4, 3],
quality: 1,
});
location = result.uri;
setImageSelected(location);
console.log(imageSelected);
}