wagslane / react-native-expo-cached-image

Cached image component for Expo's managed workflow
https://qvault.io/2020/02/04/how-to-cache-images-react-native-expo-managed
MIT License
44 stars 8 forks source link

TypeError: null is not an object #32

Open lawrence-laz opened 2 years ago

lawrence-laz commented 2 years ago

Hi, great library!

One issue I found when switching from <ImageBackground> to <CachedImage> is that the latter doesn't play nice when source is null. This is the code I have:

<CachedImage
    isBackground={true}
    source={picture && { uri: `${API_URI}pictures/${picture}` }}
>
    ... content goes here
</CachedImage>

Would it be hard to make it skip loading an image and just act as a container when source is null? This is how <ImageBackground> behaves.

lawrence-laz commented 2 years ago

Just figured out I can do

source={{ uri: picture ? `${API_URI}pictures/${picture}` : undefined }}

And it will work. So my case is covered. Leaving this open for you to decide whether it's worth investing time into covering the case above. :slightly_smiling_face: