Categories
Mastering Development

REACT-NATIVE: Images appear when uploaded but stop appearing at one point

I’m coding a React-Native app with expo where users can upload pictures from their camera roll.

I successfully retrieve the uri of the image and it appears on the screen, it even appears when I call it on different pages from the database. The problem is that when I log out for a while and log back in, the pictures don’t appear anymore. When I console log the uri shows up but the image doesn’t. Also when I upload from phone A and I log in the app with phone B, I don’t see the images (should mention that phone A is Android and phone B is iOS).

Thank you so so much for your help!

Here is my code

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

      _pickImage = async () => {
    try {
        let result = await ImagePicker.launchImageLibraryAsync({
            mediaTypes: ImagePicker.MediaTypeOptions.All,
            allowsEditing: true,
            aspect: [5, 7],
            quality: 1,
        });
        if (!result.cancelled) {
            this.setState({ image: result.uri });
        }
        console.log('results', result);
    } catch (E) {
        console.log(E);
    }
};

the console.log

    Object {
      "cancelled": false,
      "height": 1080,
      "type": "image",
      "uri":
            "file:///data/user/0/host.exp.exponent/cache/ExperienceData/%2540userone%252Fmyapp/
             ImagePicker/5d8acfbe-64b8-406b-835b-46f3f7b22203.jpg",
     "width": 1080,
    }

And the view as soon as I pick an image, I tried without isStatic it’s the same thing

     <View style=>
                    <TouchableOpacity onPress={this._pickImage}>
                        <Text style=> + </Text>
                    </TouchableOpacity>
                   {image && <Image source= style= />}
                </View>

Here you can see one image that I just uploaded from my phone with 4 others that I uploaded on different days from the same phone

Leave a Reply

Your email address will not be published. Required fields are marked *