Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

162
Views
React Native, showing images dynamically

I'm currently working on a page where I want to display all images in a folder. I tried the code below:

return (
 <View>
  {images.map(r => 
   <Image source={require('../assets/image/' +r+'.png')} />
  )}    
 </View>
);

Here is the result I am getting:

Error: pages/etc.js:Invalid call at line: require('../assets/image/' + r + '.png')

What should I do to fix this problem? Thanks.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

require in this specific case in React Native does not work with dynamic routes (routes with variables). An image should be required with its pur string path. What you want could be done for example with something like this:

//.....
const images =[require('../assets/image/1.png'),require('../assets/image/2.png')]
//.....
return (
 <View>
  {images.map(i => 
   <Image source={{uri:i}} />
  )}    
 </View>
);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!