Mi código a continuación acepta inputPhotoLocation como accesorio. inputPhotoLocation contiene una lista de ubicaciones de fuentes de imágenes (que se han recuperado de un archivo que contiene una lista). Necesito una forma de pasarlos a mi fuente de imagen. He podido pasar las ubicaciones directamente en el cuadro de texto con éxito.
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> Mi accesorio inputPhotoLocation contiene esto:
./assets/GroupImages/football.jpg
../assets/GroupImages/valley.jpg
../assets/GroupImages/usa.jpg
../assets/GroupImages/playstation.jpg
../assets/GroupImages/pc.jpg
Puedo pasar estas ubicaciones como salidas de texto con éxito. Sin embargo, no puedo averiguar cómo pasar estos en la fuente de la imagen.
<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>