react-native-expo-cached-image icon indicating copy to clipboard operation
react-native-expo-cached-image copied to clipboard

TypeError: null is not an object

Open lawrence-laz opened this issue 3 years ago • 1 comments

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 avatar Dec 02 '21 22:12 lawrence-laz

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:

lawrence-laz avatar Dec 02 '21 22:12 lawrence-laz