how to include local image in javascript code example
Example 1: how to include local image files in javascript object
const images = [
{ id: 1, src: './assets/image01.jpg', title: 'foo', description: 'bar' },
{ id: 2, src: './assets/image02.jpg', title: 'foo', description: 'bar' },
{ id: 3, src: './assets/image03.jpg', title: 'foo', description: 'bar' },
{ id: 4, src: './assets/image04.jpg', title: 'foo', description: 'bar' },
{ id: 5, src: './assets/image05.jpg', title: 'foo', description: 'bar' },
...etc
];
export default images;
Example 2: how to include local image files in javascript object
import images from './images'
{ images.map(({id, src, title, description}) => <img key={id} src={src} title={title} alt={description} />)