Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

142
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda