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

143
Views
How do I pass a prop that contains the image location to image source when rendering many images in a flatlist?

My code below accepts inputPhotoLocation as a prop. inputPhotoLocation contains a list of image source locations (which have been retrieved from a file containing a list). I need a way to pass these to my image source. I have been able to pass the locations directly in the text box with success.

function SelectionBoxComponent({inputPhotoLocation, inputText, onPress}) {
    return (

        <TouchableWithoutFeedback onPress={onPress}>
            <View style={styles.box}>
                <View style={styles.circularPhoto}>
                    <Image style={{height:"100%", width:"100%", borderRadius:70,
                        borderWidth:0, source={require(inputPhotoLocation)}}} ></Image> {/* Here I need to insert the list items */}
                </View>

                <AppText style={styles.textStyle} onPress={console.log(inputText)} >
                    {inputText}</AppText>

            </View>
        </TouchableWithoutFeedback>

My inputPhotoLocation prop contains this:

./assets/GroupImages/football.jpg

../assets/GroupImages/valley.jpg

../assets/GroupImages/usa.jpg

../assets/GroupImages/playstation.jpg

../assets/GroupImages/pc.jpg

I am able to pass these locations as text outputs successfully. However, I can't figure out how to pass these in the image source.

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

0

      <Image
        style={{
          height: '100%',
          width: '100%',
          borderRadius: 70,
          borderWidth: 0,
          {/* The source prop is not a style prop */}
          source={require(inputPhotoLocation)
        }}></Image>



      <Image
        {/* The source prop is Image prop */}
        source={require(inputPhotoLocation)
        style={{
          height: '100%',
          width: '100%',
          borderRadius: 70,
          borderWidth: 0
        }}></Image>
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!