In my react-native project I am trying to require images from a variable, but I am getting an error: This call is not symbolicated. If I hardcode the string in require, the import works.
const exampleImagesIos = ["./example-images/example-ios-1.png", "./example-images/example-ios-2.png"]
<Swiper>
{exampleImagesIos.map((item, i) => (
<View key={i} style={styles.exampleImgContainer2}>
<Image style={styles.exampleImgstyle2}
source={require(item)}
/>
</View>
))}
</Swiper>
CodePudding user response:
Dynamic imports does not work in require it only works in import. see Diff between Require and import
so you have to pass static value you can use this
const exampleImagesIos = [require("./example-images/example-ios-1.png"), require("./example-images/example-ios-2.png")]
and use the direct item in source of image
see this Stackoverflow question for more details