Image headers unsupported when an array of sources is provided
See original GitHub issueI’m trying to use the new headers
prop on images in Android. I’ve managed to get it working on Android but it didn’t behave as expected (and I believe its undocumented so was guessing on how to use it).
For a simple image source it works fine, something like this:
<Image source={uri: foo, headers: {Authorization: bar}} ...
But in my case I want to pass an array of different sized images. I assumed this would be the correct approach:
<Image source={[
{uri: foo, headers: {Authorization: fooHeader},
{uri: bar, headers: {Authorization: barHeader} ...
But that doesn’t work (and the error message that comes back when my auth fails does seem to have any information in it). Looking at this code, I noticed that it always expects the headers
prop to be at the top level, so one headers prop for all images (unlike the cache
prop which is one per uri). As the source object is an array, so I ended up with something like this:
const sourceArray = [[uri: foo], [uri: bar]];
sourceArray.headers = headers;
Is this by design? It doesn’t feel quite right to me - I was expecting the headers
prop to be treated more the the cache
prop. Having said that, I can’t see any evidence of the cache
header being implemented in android.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (4 by maintainers)
Looks like #16155 was merged, thanks @phillip055
Hey, thanks for reporting this issue! It looks like your description is missing some necessary information, or the list of reproduction steps is not complete. Can you please add all the details specified in the Issue Template? This is necessary for people to be able to understand and reproduce the issue being reported. I am going to close this, but feel free to open a new issue with the additional information provided. Thanks! See “What to Expect from Maintainers” to learn more.