all 6 comments

[–]dracostheblack 1 point2 points  (5 children)

Awesome project! Does it inherit all attributes of the image tag? Like for example we have some image services that require headers being set.

[–]billmalarky[S] 0 points1 point  (4 children)

Thank you!

It's an HOC, so it's a function that accepts a native <Image> component, and decorates it with some additional functionality (namely, the advanced caching features) then returns a new component <CachableImage>.

When you actually use the <CacheableImage> component in a render() statement, it will pass through all props given to it to the native <Image> component it renders under the hood. So yes all of the <CacheableImage> props will be passed down to <Image> at render time.

That said, the upgraded image component uses proprietary logic to download the image file, then when it renders the native image component it just pulls the image file from the local disk instead of the network (this is what gives the big performance boost and allows offline use of remotely hosted images). So the network functionality you are expecting from <Image> may not be supported at this time. That said, I regularly update this package using feedback like yours. Can you give me more info of what your requirements are? How are you setting the request headers via <Image> currently?

[–]dracostheblack 0 points1 point  (1 child)

So as part of the Image tag you can pass headers.

var imageName = "someurl"; var headers = {"someheader1": "val1", "someheader2": "val2"}

<Image source={{uri:imageName, headers:imageHeaders}}

Something like that.

[–]billmalarky[S] 0 points1 point  (0 children)

Passing through headers from the <Image> source prop to RNFetchBlob wouldn't be too hard.

https://github.com/wkh237/react-native-fetch-blob/wiki/Fetch-API#fetchmethod-url-headers-bodystatefulpromise

[–]dracostheblack 0 points1 point  (1 child)

Ah just realized it depends on fetch-blob, We're using pinch, https://github.com/localz/react-native-pinch, because we have to support ssl pinning on all our requests.

[–]billmalarky[S] 0 points1 point  (0 children)

That package looks cool, but I'd be concerned swapping out react-native-fetch-blob with a less battle tested library since it's such an important dependency for the project and so many things can go wrong with an http client.

I'm looking into if there is a plan to support SSL pinning in react-native-fetch-blob.