Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

411
Views
"No default value" error with expo Image Picker

I created this Image Input component

const ImageInputComponent = ({onImagePicked} : {onImagePicked : (blob : Blob | null) => void}) => {
  const [image, setImage] = useState("");

  return (
    <TouchableOpacity style={styles.container}
        onPress={async () => {
            const imageUrl = await PickImage();
            if (imageUrl) {
                setImage(imageUrl);
                const blob = await ConvertUriToBlob(imageUrl);
                onImagePicked(blob);
            } else {
                onImagePicked(null);
            }
        }}
    >
        <Image source={{uri: image}} style={styles.image} resizeMode="cover"/>
    </TouchableOpacity>
  )
}

That uses this customs hooks with expo image picker, and other that converts the uri to a blob to upload it to firebase

import * as ImagePicker from 'expo-image-picker';

const PickImage = async () => {
    let result = await ImagePicker.launchImageLibraryAsync({
      mediaTypes: ImagePicker.MediaTypeOptions.All,
      allowsEditing: true,
      aspect: [4, 3],
      quality: 1,
    });

    if (!result.cancelled) return result.uri;
};

const ConvertUriToBlob = async (uri : string) => {
    const response = await fetch(uri);
    const blob = await response.blob();
    return blob;
}

But when i try to use it in a screen, it doesn't seem to return anything, and when i navigate to another screen it throws the error "No default value"

const StoreDetails = () => {
  const navigation = useNavigation();

  const [images, setImages] = useState<Blob[]>([]);

  const updateImagesArray = (image: Blob, index: number) => {
    let newImages = images;
    newImages[index] = image;
    setImages(newImages);
  }
  
  return (
    <View>
        <View style={styles.imageContainer}>
            <ImageInput onImagePicked={(image) => {if(image) updateImagesArray(image, 0)}}/>
            <ImageInput onImagePicked={(image) => {if(image) updateImagesArray(image, 1)}}/>
            <ImageInput onImagePicked={(image) => {if(image) updateImagesArray(image, 2)}}/>
        </View>

        <TouchableOpacity
            onPress={() => navigation.navigate('RegisterProducts', {data: {images}})}
        >
            <Text>SIGUIENTE</Text>
        </TouchableOpacity>
    </View>
  )
}

How can i fix this? or what other way can i do this?
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!