How to import a folder with multiple images inside

Hello i am working in React and i want to import a folder with 1000+ images to use them in different components. How can i do that? All the images have as name an defined id which i will use later. I just need to import them all at once from the folder and save their names as an array. I tryed some codes from the net like this: import React from 'react'; const images = require.context('../../images', true); const imageList = images.keys().map(image => images(image)); function ImageGallery() { return ( <div> {imageList.map((image, index) => ( <img key={index} src={image.default} alt={image-${index}} /> ))} </div> ); } export default ImageGallery; But it says me require.contect undefined
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server