react-native-fast-image: Crash on Android if source is an invalid URL

If I pass as source an object like this { uri: 'INVALID_URL' } I get the following error on Android:

Error while updating property 'source' of a view managed by: FastImageView

null

Must not be null or empty

At the moment I am normalising the source using this (ugly) code to avoid the crash:

const normalisedSource = source && typeof source.uri === 'string' && !source.uri.split('https://')[1] ? null : source;

but I think it would be better if the library prevents it.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 13
  • Comments: 15

Most upvoted comments

not all image start https, http ?? const normalisedSource = source && typeof source.uri === ‘string’ && !source.uri.split(‘http’)[1] ? null : source;

I think the library itself should take of this issue, on ios it works perfectly.

render() { return ( <FastImage source={{uri: this.getUriImage(_uri)}}/> ) }

function getUriImage(uri) { return uri !== null && uri !== undefined && uri.includes(“/”) && uri.includes(“.”) ? uri : “” }

render() { return ( <FastImage source={{uri: this.getUriImage(_uri)}}/> ) }

function getUriImage(uri) { return uri !== null && uri !== undefined && uri.includes(“/”) && uri.includes(“.”) ? uri : “” }

Thanks you, my problem is solved using this

not all image start https, http ?? const normalisedSource = source && typeof source.uri === ‘string’ && !source.uri.split(‘http’)[1] ? null : source;

not all images start with https or http. what about local images

so I need adjust every source ? It’s so Unfriendly!!!

image

this is log.

2019-03-28 19:29:08.185 14848-14848/E/fastimage: http://img.abc.com/o_1d6v24em310p7pib14b94gsjbha.jpg
2019-03-28 19:29:08.185 14848-14848/ E/fastimage: false
2019-03-28 19:29:08.195 14848-14848/ E/fastimage: true
2019-03-28 19:29:08.196 14848-14848/E/unknown:ViewManager: Error while updating prop source
    java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)


 Caused by: java.lang.ClassCastException: Value for uri cannot be cast from ReadableNativeMap to String

not all image start https, http ??

where do i have do make this change?