I try to dynamically display a list of local images, which are stored in the folder .img/. React Native throws the error „Unknown named module: ‚./img/a1.jpg‘ with my implementation. I read about the problem of dynamically requiring images, but wasn’t able to solve the problem. Do you have any suggestions?
export class ImageList extends React.Component { constructor() { super(); } render() { const datav2 = [ "./img/a1.jpg", "./img/a6.jpg" ]; const lapsList = datav2.map((data) => { var testPath = require(data); return ( <View> <Image source={testPath} style={{width: 50, height: 50, backgroundColor: "#33ff00"}} /> </View> ) }) return ( <View> {lapsList} </View> ); } } 