I am currently developing a sheet music app that uses a carousel. I push the song_item
data from the previous screen to the new screen. The song_path
in the loop exists in the console.log. What i need is for images2
to be the same as the images
array. The images
array is hardcoded for development purpuses. Thank you.
const { itemId, songs_item } = route.params;
console.log("SONGS #################",songs_item['songs'])
var songs = songs_item['songs']
var images = [
require('../assets/songs/lala.jpg'),
require('../assets/songs/δοκιμη.jpg'),
require('../assets/songs/lala.jpg'),
]
let images2 = []
songs.forEach((song, i) => {
const song_path = "../assets/"+song['path'];
// const rew = require(song_path);
console.log(song_path)
// images2.push(rew);
})
It throws an invalid call
for require
when uncommenting the lines.
UPDATE
Also why cant it work when i uncomment const path = song['path']
but it works when const path = 'songs/lala.jpg';
?
let images2 = [];
songs_item['songs'].forEach((song, i) => {
console.log(song['path'])
const path = 'songs/lala.jpg';
//const path = song['path']
// console.log('PATHHHHHHHHHHHH',path)
images2.push(require('../assets/'+path))
})
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…