1

i have a list of text and images, I get the name of the image from Firebase database and then concatenate the extracted name with a the path of the images' folder under my project: that's the code i used

var icon= require ('path/'+item.image+'.png') return ( ... <Image style={{width: 50, height: 50}} source={icon}/> 

The images are displayed but i have warnings as much as i have images in the list i read somewhere this

REQUIRE('IMAGE!...') NO LONGER SUPPORTED

Support for require('image!…'), which has been deprecated for a long time, is now removed. If you are still loading images that way in your apps, make sure to check the documentation for alternatives.

enter image description here

1 Answer 1

2

There is no explicit question being asked, so I will assume you're asking "what does this error mean?" and "what, if anything, should I do to make it go away?".

The require('image!...') is the (really) old way of using images in React Native. But I suspect your issue here is that you're building the image name dynamically.

See the React Native docs on images:

In order for this to work, the image name in require has to be known statically.

// GOOD <Image source={require('./my-icon.png')} /> // BAD var icon = this.props.active ? 'my-icon-active' : 'my-icon-inactive'; <Image source={require('./' + icon + '.png')} /> // GOOD var icon = this.props.active ? require('./my-icon-active.png') : require('./my-icon-inactive.png'); <Image source={icon} /> 

So don't build your image name dynamically.

Yes, I feel your pain for having to write a switch-case for all countries of the world...

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you .. this solution worked perfectly fine although i had to make a massive switch case just like you said

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.