Navigate back to the homepage

React Native Image

Infinitbility
React Native
November 8th, 2020 · 1 min read
React Native Image

Hello Friends,

Welcome To Infinitbility!

React Native provide <image /> component for adding image statically or dynamically for your app.

Today we see how to add static, dynamic, and data:base64 images.

For importing image component from react native write like below.

1import { Image } from 'react-native';

Table of Contents

  • Static Image
  • Dynamic Image
  • Data Image

Static Image

React Native provides a unified way of managing images and other media assets in your Android and iOS apps. To add a static image to your app, place it somewhere in your source code tree and reference it like this:

1<Image source={require('./icon.png')} />

Dynamic Image

To add a dynamic image to your app, place it somewhere in your server and reference it like this:

1<Image source={{uri: 'https://infinitbility.com/preview.jpg'}} />

Data image

To add a data:base64 image to your app, reference it like this:

1<Image
2 style={{
3 width: 51,
4 height: 51,
5 resizeMode: 'contain'
6 }}
7 source={{
8 uri:
9 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADMAAAAzCAYAAAA6oTAqAAAAEXRFWHRTb2Z0d2FyZQBwbmdjcnVzaEB1SfMAAABQSURBVGje7dSxCQBACARB+2/ab8BEeQNhFi6WSYzYLYudDQYGBgYGBgYGBgYGBgYGBgZmcvDqYGBgmhivGQYGBgYGBgYGBgYGBgYGBgbmQw+P/eMrC5UTVAAAAABJRU5ErkJggg=='
10 }}
11/>

Tips

provide all-time height and width for images. it will improve your app performance.

if you get help, please share post on your social network

More From React Native Tutorial

Basics

  1. Introduction To React Native
  2. React Native Environment Setup using expo
  3. React Native Environment Setup for windows
  4. React Native Environment setup on Mac OS
  5. React Native Environment setup on linux
  6. React Native Project Structure
  7. React Native State
  8. React Native Props
  9. React Native Styling
  10. React Native Flexbox
  11. React Native Text
  12. React Native Textinput
  13. React Native Commands
  14. React Native ScrollView

Advances

  1. React Native Dark Mode
  2. React Native Fonts
  3. React Native SQLite
  4. React Native DatepickerAndroid
  5. React native ScrollView scroll to position
  6. How to align icon with text in react native
  7. React Native Image
  8. React Native Firebase Crashlytics
  9. React Native Async Storage
  10. React Native Share

Error & Issue Solution

  1. Task :app:transformDexArchiveWithDexMergerForDebug FAILED In React Native
  2. Expiring Daemon because JVM heap space is exhausted In React Native
  3. Task :app:transformNativeLibsWithMergeJniLibsForDebug FAILED In React Native
  4. Unable to determine the current character, it is not a string, number, array, or object in react native
  5. App crashed immediately after install react native video or track player
  6. how to delete SQLite database in android react native
  7. React native material dropdown twice click issue
  8. How to get the current route in react-navigation?
  9. how to disable drawer on the drawer navigation screen?
  10. Image not showing in ios 14 react native
  11. React Native image picker launchimagelibrary on second time issue
  12. how to open any link from react native render Html

Looking For React Native Tutorial?

we are trying to create the best Tutorial for react native developers.

When you want a daily updates about React Native Tutorial or infinitbility update subscribe to our newsletter.

Read React Native Tutorial

Request New Tutorial or Article on mail [email protected]

Join our email list and get notified about new content

No worries, I respect your privacy and I will never abuse your email.

Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.

More articles from Infinitbility

how to add datePickerAndroid in react native with color changes?

how to add datePickerAndroid in react native with color changes?

the simplest way to add datePickerAndroid in react native with color changes.

October 30th, 2020 · 1 min read
How to get the current route in react-navigation?

How to get the current route in react-navigation?

the simplest way to get current route name from react navigation.

October 25th, 2020 · 1 min read
© 2020–2021 Infinitbility
Disclaimer
Link to $https://medium.com/infinitbilityLink to $https://www.facebook.com/InfinitbilityLink to $https://github.com/infinitbilityLink to $https://twitter.com/infinitbilityLink to $https://www.buymeacoffee.com/infinitbilityLink to $mailto:[email protected]