1

I have a folder assets/images with 200 images. I want to make a listView with all the images and the image's file name would be the Text on the list view.

I've tried to make

import Images from './assets/images'

but always give me error.

Im using react-native version: 0.59.9 and React: 16.8.3

I try to make import folder:

import Images
Gelxxxx
  • 161
  • 1
  • 17

1 Answers1

3

you cannot do it like that..

Add an index.js file inside images folder

 const images = {
  button: require('./button.png'),
  logo: require('./logo.png'),
  placeholder: require('./placeholder.png')
}

export default images

then import images properly

import Images from '../images'

<Image source={Images.logo}

mode the code like imports as you wish to make it working.

Victor
  • 4,171
  • 1
  • 29
  • 37