How to pass headers into Image
element?
This approach does not fit due to impossibility to cache images and base64 conversion will be hard with small RN Js-thread
https://stackoverflow.com/a/36678631/6119618
This is not working at all on neither android nor ios
https://stackoverflow.com/a/44713741/6119618
I don't want yet eject my project, so modules like FastImage
and others using react-native link
will not work
UPD
tried to launch the same app on ios and images aren't showing up. Android works
To configure the header bar of a React Native application, the navigation options are used. The navigation options are a static property of the screen component which is either an object or a function. headerTitle: It is used to set the title of the active screen. headerStyle: It is used to add style to the header bar.
Adding Image Let us create a new folder img inside the src folder. We will add our image (myImage. png) inside this folder. We will show images on the home screen.
So here is the solution to insert an image from an external URL in your application: //MyComponent. js import React from 'react'; import { Image } from 'react-native'; const imageUrl = "https://images.unsplash.com/photo-1526045612212-70caf35c14df"; export class MyComponent extends React.
The better approach would be something like this.
import { Image } from 'react-native';
<Image
source={{
uri: 'source uri',
headers: {
...headers
}
}}
/>
Above method would work for almost every case, However you can also separately fetch the image using fetch api or axios (pass the headers in the request). Then store the base64 in state and then use that as uri.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With