Answers for "load image from local storage react-native"

2

how to dynamically show image from local storage in react native

// our data
// we need to require all images, 
// so that React Native knows about them statically
const items = [
    {
        id: '001',
        image: require('../images/001.jpeg'),
    },
    {
        id: '002',
        image: require('../images/002.jpeg'),
    },
];

// render
items.map( (item) => 
    <Image key={item.id} source={item.image} />
)
Posted by: Guest on October-31-2020
0

react native preload local images

import { Image } from 'react-native';
import FastImage from 'react-native-fast-image';

export function preloadImages() {
  const images = [
    require('../assets/images/graphic1.webp'),
    require('../assets/images/graphic2.jpg'),
    require('../assets/images/graphic3.webp')
  ];

  const uris = images.map(image => ({
    uri: Image.resolveAssetSource(image).uri
  }));

  FastImage.preload(uris);
}
Posted by: Guest on December-22-2020

Code answers related to "load image from local storage react-native"

Code answers related to "Javascript"

Browse Popular Code Answers by Language